2013年9月16日星期一

JavaWeb problem , do not know what was wrong the

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)


source code 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 ();

}

------ Solution ------------------------------------ --------
put pstmt.executeUpdate ();
replaced pstmt.execute () Try
------ For reference only ----------------------- ----------------
Well, checked online , tried it does not work , probably because it did not re-released , now succeeded
---- - For reference only ---------------------------------------
extremely grateful , successful
------ For reference only ------------------------------------ ---
Well , change the background code must restart the server later , or did not work, or you can change the server automatically restarts , modify the code in the future it will automatically restart

没有评论:

发表评论