LGA*_*GAP 0 java string concatenation
请考虑将下面代码中的URL分配给字符串
String link = "http://www.topix.com/rss/city/ellensburg-wa";
Run Code Online (Sandbox Code Playgroud)
我应该如何使用下面代码中的字符串而不是URL本身.
注意:我是java的初学者
stmt.executeQuery("select url from urls where url='http://www.topix.com/rss/city/ellensburg-wa'");
stmtR.executeUpdate("insert into urls values(21211,'http://www.topix.com/rss/city/ellensburg-wa','source',1,0)"
Run Code Online (Sandbox Code Playgroud)
如果要创建一个好的查询,请使用预准备语句
PreparedStatement insertUrlStatement = con.prepareStatement("INSERT INTO urls VALUES(?, ?, ?, ?)");
//Replace the **first** "?" by an "id" variable content (containing an **int**)
insertUrlStatement.setInt(1, id);
//Replace the **second** "?" by the "url" variable content (containing a **String**)
insertUrlStatement.setString(2, url);
//Two other setXxx();
insertUrlStatement.executeUpdate()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
253 次 |
| 最近记录: |