jdbc执行insert语句总是出错?
String sql = "insert into tb_stu(name,sex,age)"+"values(?,?,?);";
pstm = conn.prepareStatement(sql);
pstm.setObject(1, student.getAge());
pstm.setObject(1, student.getName());
pstm.setObject(2, student.getSex());
pstm.setObject(3, student.getAge());
flag = pstm.executeUpdate(sql) > 0 ?true :false;
总是出错!!
错误信息:
com.mysql.jdbc.exceptions.jdbc4.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 JDBC SQL MySQL
[解决办法]