Java delete语句中的语法错误
我试图从我的“student”表中删除该记录,该表有两列rollno和student name 我正在使用一个Java delete语句中的语法错误,java,mysql,sql,jdbc,Java,Mysql,Sql,Jdbc,我试图从我的“student”表中删除该记录,该表有两列rollno和student name 我正在使用一个PreparedStatement,但是我得到了一些错误。我不能理解这个错误。错误是: 您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以了解第1行“?”附近使用的正确语法 这是我的密码 String query = "delete from student where rollno = ?"; PreparedStatement pst = con.pre
PreparedStatement
,但是我得到了一些错误。我不能理解这个错误。错误是:
您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以了解第1行“?”附近使用的正确语法
这是我的密码
String query = "delete from student where rollno = ?";
PreparedStatement pst = con.prepareStatement(query);
pst.setInt(1, 7);
pst.executeUpdate(query);
您很可能是这样调用execute:
pst.executeUpdate(query);
这将执行原始查询,而不使用之前设置的参数
您希望执行准备好的查询,因此只需使用:
pst.executeUpdate();
您很可能是这样调用execute:
pst.executeUpdate(query);
这将执行原始查询,而不使用之前设置的参数
您希望执行准备好的查询,因此只需使用:
pst.executeUpdate();
您忘记共享最重要的部分:如何执行查询?您忘记共享最重要的部分:如何执行查询?