如下图所示:
在上图的代码中,executeQuery()中被加亮显示,测试正常通过;而executeUpdate()不被加亮显示,测试不能通过,错误代码如下:
exception
org.apache.jasper.JasperException: Exception in JSP: /DataInsertB.jsp:20
17: String strcon = "jdbc:odbc:Driver={Microsoft Access Driver
(*.mdb)};DBQ=D:/Apache/www/DataBase/Book.mdb";
18: Connection con = DriverManager.getConnection(strcon,"","");
19: Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
20: stmt.executeUpdate(sql);
21: sql="select * from 图书明细表";
22: ResultSet rs = stmt.executeQuery(sql); %>
23: <table border="1" align="center" bordercolor="#7188e0">
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: [Microsoft][ODBC Microsoft Access Driver] 查询值的数目与目标字段中的数目不同。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.DataInsertB_jsp._jspService(DataInsertB_jsp.java:104)
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
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 查询值的数目与目标字段中的数目不同。
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:288)
org.apache.jsp.DataInsertB_jsp._jspService(DataInsertB_jsp.java:63)
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)
[此贴子已经被作者于2007-8-9 21:37:46编辑过]