关于JSP调用MySQL时更新数据的问题
各位高手,我今天用JSP调用MySQL数据时成功,但是在更新字段数据时出现了问题,这个情况在用SQL Server 2000时不存在;我的系统配置如下:WinXP,Tomcat 5.5.23,j2sdk1.4.1_02;
出现的错误情况为:
org.apache.jasper.JasperException: Exception in JSP: /tree/updateHits.jsp:31
28:
29: intHits=rs.getInt(8)+1;
30: out.print("<br>点击数:"+intHits);
31: rs.updateInt("hits",intHits);
32: //strSQL="update ListPCSkill set hits="+intHits+" where ID="+sID;
33: //rs.close();
34: rs.updateRow();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.tree.updateHits_jsp._jspService(updateHits_jsp.java:151)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
com.mysql.jdbc.NotUpdatable: Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.
com.mysql.jdbc.UpdatableResultSet.generateStatements(UpdatableResultSet.java:1849)
com.mysql.jdbc.UpdatableResultSet.syncUpdate(UpdatableResultSet.java:1970)
com.mysql.jdbc.UpdatableResultSet.updateInt(UpdatableResultSet.java:1373)
com.mysql.jdbc.UpdatableResultSet.updateInt(UpdatableResultSet.java:1399)
org.apache.jsp.tree.updateHits_jsp._jspService(updateHits_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
请高手帮帮忙看怎么回事,谢谢。
--转自