【发布时间】:2013-11-06 14:56:52
【问题描述】:
我有一个简单的代码,可以将一些信息发送到 mysql。
Connection connection = null;
Statement stmt;
Properties connInfo = new Properties();
connInfo.put("user", "Main");
connInfo.put("password", "poiuyt");
connection = DriverManager.getConnection("jdbc:mysql://localhost/ABCNews", connInfo);
String sql = "insert into abcnews_topics VALUES (null, '" + text_topic + "');";
stmt = (Statement) connection.createStatement();
stmt.executeUpdate(sql);
“text_topic”它是我信息的变量。 这段代码我在循环中,并且在每一步中我的变量(text_topic)的值都会改变。
我想使用Prepared Statements代替我的决定。 怎么办?
【问题讨论】:
-
网上很多例子,你都没搜过吗?
-
我当然会搜索,但我的测试总是出错。