【发布时间】:2016-04-15 14:22:30
【问题描述】:
我有一个数据库,我需要在其中插入一条新记录。我尝试使用 PreparedStatement。
//Executing the INSERT query
String addSql = "INSERT INTO savedforms (Patientfnr, Patientname) VALUES (?, ?)";
//PreparedStatement for INSERT sql
java.sql.PreparedStatement stmt1 = connection.prepareStatement(addSql);
stmt1.setString(1, patientnumber);
stmt1.setString(2, patientname);
//Execute query
stmt1.executeUpdate(addSql);
并得到以下错误:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?, ?)' at line 1
如何解决?
【问题讨论】:
标签: java mysql jdbc prepared-statement