在写数据库删除操作的时候,遇到了一些问题
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
参考:https://blog.csdn.net/cherishme1988/article/details/7399225
之前由于是删除操作,就写成了
sql = con.prepareStatement(condition);
ResultSet rSet = sql.executeQuery(condition);
实际上由于是删除,
应该该成这样子:st.execute(“insert into student values(’”+name+"’,’"+age+"’,’"+introduce+"’)") ;
最后总结:如果你的SQL 语句是诸如update,insert的更新语句,应该用statement的execute()方法,如果用的是statement的executeQuery()就会出现上述问题
sql = con.prepareStatement(condition);
sql.execute(condition);
这样就能成功在mysql中删除