日期:2014-05-17  浏览次数:20767 次

JavaWeb的问题,不知道错哪了
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.Statement.checkForDml(Statement.java:417)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1383)
at src.com.sdust.dao.ComplainDaoImpl.updateComplain(ComplainDaoImpl.java:51)
at src.com.sdust.service.ComplainServiceImpl.updateComplain(ComplainServiceImpl.java:21)
at src.com.sdust.servlet.ComplainServlet.doPost(ComplainServlet.java:69)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)


源代码为public void updateComplain(String type, String id) {
// TODO Auto-generated method stub

Connection conn=null;
PreparedStatement pstmt=null;
String sql="update complain set type=? where Id=?";

try {
conn=DbUtils.getConnection();
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, type);
pstmt.setString(2, id);
pstmt.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
DbUtils.closeResult(rs);
DbUtils.closeStatement(pstmt);
DbUtils.closeConnection();

}