java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1084)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918)
at com.mysql.jdbc.StatementImpl.checkForDml(StatementImpl.java:501)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2150)
at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:107)
at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:107)
at com.peace.dao.impl.MsgDaoImp.insertMsg(MsgDaoImp.java:90)
at com.peace.service.impl.MsgServiceImpl.add(MsgServiceImpl.java:22)
at com.peace.servlet.InsertServlet.service(InsertServlet.java:42)
...
错误原因:
解决方法:
//增
PreparedStatement pst = null;
pst = conn.prepareStatement(sql);
pst.executeQuery();
/* executeQuery():使用情况 => 新增、修改、删除
* executeQuery():使用情况 => 查
*/