[Microsoft][ODBC Microsoft Access Driver] 试图将 Null 值赋予一个非 Variant 数据类型的变量

      今天写代码的时候遇到了一个这样的小问题记录下来(使用的是access数据库)

sun.jdbc.odbc.JdbcOdbcBatchUpdateException: [Microsoft][ODBC Microsoft Access Driver] 试图将 Null 值赋予一个非 Variant 数据类型的变量。 at sun.jdbc.odbc.JdbcOdbcPreparedStatement.emulateExecuteBatch(JdbcOdbcPreparedStatement.java:2165) at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeBatchUpdate(JdbcOdbcPreparedStatement.java:1783) at sun.jdbc.odbc.JdbcOdbcStatement.executeBatch(JdbcOdbcStatement.java:912) at hicc.cn.exam.dao.impl.UserDaoImpl.importBanji(UserDaoImpl.java:1275) at org.apache.jsp.user.importData_jsp._jspService(importData_jsp.java:71) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) 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 hicc.cn.exam.filter.UserLoginPermissionsFilter.doFilter(UserLoginPermissionsFilter.java:34) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 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) 2011-1-14 20:20:42 org.apache.catalina.core.StandardWrapperValve invoke

其实这也不算是一个大的问答题,就是一个细节问题。说一下为什么会出这样的问题:数据库的某表中id字段是‘自动编号’,我习惯性的在写添加记录的sql语句时写成了这样:"insert into **(id, name) values(null, ?)"。就是因为这样所以出现了这样的错误,给自动编号的字段添加了null值。以前一直用的是mysql数据库,这样的语句在mysql数据库中是没问题的。以后注意!!!!

                                                                                                                                                                     ------王康

你可能感兴趣的:(JavaWeb)