org.apache.jasper.JasperException: Exception in JSP: /Post.jsp:3633:  rs.next();
34:  int key = rs.getInt(1);
35:  rs.close();
36:  stmt.executeUpdate("update article set rootid = " + key + "where id =" + key);
37: 
38:  conn.commit();
39:  conn.setAutoCommit(true);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:489)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause javax.servlet.ServletException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id =29' at line 1
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.Post_jsp._jspService(Post_jsp.java:125)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id =29' at line 1
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1051)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2562)
com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1664)
com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1583)
org.apache.jsp.Post_jsp._jspService(Post_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

解决方案 »

  1.   

    33: rs.next();
    34: int key = rs.getInt(1);
    35: rs.close();
    36: stmt.executeUpdate("update article set rootid = " + key + "where id =" + key);
    -------------------
    LZ 你到底是最更新还是查询啊 == 还有,如果是查询的话,rs.close()会报错,用try{}tach(){} ,做更新的话你就用不到结果集了吧。
      

  2.   


    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id =29' at line 1
    语法错误,建议先在命令行测试这条sql语句。
      

  3.   

    太明显的错误,where前面少一个空格