我如何做出准备好的陈述?
我怎样才能对此做出一份准备好的声明?
Statement stmt = con.createStatement();
long lastid = getLastId(stmt);
// create a SQL query
String strQuery = "INSERT INTO studenten " +
" (id, naam, adres, postcode, plaats, geboren) " +
" VALUES (" + (lastid+1) + "," +
"'" + contact.getNaam() + "'," +
"'" + contact.getAdres() + "'," +
"'" + contact.getPostcode() + "'," +
"'" + contact.getPlaats() + "'," +
"{d '" + contact.getGeboren() + "'}" +
") ";
stmt.executeUpdate(strQuery);
stmt.close();
con.close();
How can I make an prepared statement of this one?
Statement stmt = con.createStatement();
long lastid = getLastId(stmt);
// create a SQL query
String strQuery = "INSERT INTO studenten " +
" (id, naam, adres, postcode, plaats, geboren) " +
" VALUES (" + (lastid+1) + "," +
"'" + contact.getNaam() + "'," +
"'" + contact.getAdres() + "'," +
"'" + contact.getPostcode() + "'," +
"'" + contact.getPlaats() + "'," +
"{d '" + contact.getGeboren() + "'}" +
") ";
stmt.executeUpdate(strQuery);
stmt.close();
con.close();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要用问号
?
替换值作为占位符。另请参阅:
You need to substitute values with question marks
?
as placeholders.See also:
这是一个更好的方法:
Here is a better way to do it: