java.sql.SQLException: Can not issue data manipulation statements with executeQuery().

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():使用情况 => 查
*/

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Xxacker/article/details/85304362
今日推荐