spring的JDBC应用mysql数据库的问题

当出现下面错误时:

java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
   at com.mysql.jdbc.StatementImpl.checkForDml(StatementImpl.java:436)
   at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2176)
   at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
   at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
   at com.cp.dsd.UserDAO.insert(UserDAO.java:33)
   at com.cp.dsd.SpringDAODemo.main(SpringDAODemo.java:16)

原因是:进行数据的insert、update等操作时,不能用statement的executeQuery()方法,要改为execute()方法。

posted on 2015-12-17 21:56  天涯弑  阅读(197)  评论(0编辑  收藏  举报

导航