Mybatis + springmvc + sqlite: not tangle, mybatisspringmvc
1 java. SQL. SQLException: NYI
2 org. sqlite. RS. getColumnClassName (RS. java: 269)
When configuring mybatis + springmvc + sqlite,
<Insert id = "saveUser" parameterType = "User" keyProperty = "id" useGeneratedKeys = "false"> <selectKey keyProperty = "id" resultType = "int" order = "BEFORE"> SELECT seq + 1 as seq FROM sqlite_sequence WHERE (name = 't_ demo ') // sqlite does not automatically add 1, so it is manually </selectKey> insert into t_demo (id, name, age, sex) values (# {id}, # {name }, # {age },# {sex}) </insert>
I encountered the following problems:
1 root cause
org.springframework.jdbc.UncategorizedSQLException: Error selecting key or setting result to parameter object. Cause: java.sql.SQLException: NYI; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; NYI; nested exception is java.sql.SQLException: NYI
2 root cause
java.sql.SQLException: NYIorg.sqlite.RS.getColumnClassName(RS.java:269)
Because there is little integration information on SQLite on the Internet (Baidu, Google, searched all over, even the examples on the mybatis official website), I am tossing myself for about four days, I am tired of seeing this error every day.
The insert statement needs to be configured in mapper. xml for mybatis configuration, and ID auto-increment is the biggest problem. I have done it for PostgreSQL, thinking
SQLite should be similar, and the result is always an error, specifically:
1 type Exception report 2 3 message 4 5 description The server encountered an internal error () that prevented it from fulfilling this request. 6 7 exception 8 9 org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: Error selecting key or setting result to parameter object. Cause: java.sql.SQLException: NYI 10 ; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; NYI; nested exception is java.sql.SQLException: NYI 11 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656) 12 org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) 13 javax.servlet.http.HttpServlet.service(HttpServlet.java:641) 14 javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 15 16 17 root cause 18 19 org.springframework.jdbc.UncategorizedSQLException: Error selecting key or setting result to parameter object. Cause: java.sql.SQLException: NYI 20 ; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; NYI; nested exception is java.sql.SQLException: NYI 21 org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83) 22 org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) 23 org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) 24 org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71) 25 org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365) 26 com.sun.proxy.$Proxy10.insert(Unknown Source) 27 org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:237) 28 com.sinaapp.mydemo27.daoimpl.UserDaoImpl.inseartUser(UserDaoImpl.java:20) 29 com.sinaapp.mydemo27.service.UserService.insertUser(UserService.java:30) 30 com.sinaapp.mydemo27.service.UserService$$FastClassByCGLIB$$8193c93a.invoke(<generated>) 31 net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191) 32 org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688) 33 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 34 org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) 35 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 36 org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621) 37 com.sinaapp.mydemo27.service.UserService$$EnhancerByCGLIB$$3e2827df.insertUser(<generated>) 38 com.sinaapp.mydemo27.controller.UserController.handleInseart(UserController.java:55) 39 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 40 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 41 sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 42 java.lang.reflect.Method.invoke(Unknown Source) 43 org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) 44 org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) 45 org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) 46 org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) 47 org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) 48 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) 49 org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) 50 javax.servlet.http.HttpServlet.service(HttpServlet.java:641) 51 javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 52 53 54 root cause 55 56 java.sql.SQLException: NYI 57 org.sqlite.RS.getColumnClassName(RS.java:269) 58 org.apache.ibatis.executor.resultset.FastResultSetHandler$ResultColumnCache.<init>(FastResultSetHandler.java:585) 59 org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSets(FastResultSetHandler.java:151) 60 org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:57) 61 org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:70) 62 org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:57) 63 org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267) 64 org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:141) 65 org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105) 66 org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) 67 org.apache.ibatis.executor.keygen.SelectKeyGenerator.processGeneratedKeys(SelectKeyGenerator.java:65) 68 org.apache.ibatis.executor.keygen.SelectKeyGenerator.processBefore(SelectKeyGenerator.java:41) 69 org.apache.ibatis.executor.statement.BaseStatementHandler.generateKeys(BaseStatementHandler.java:127) 70 org.apache.ibatis.executor.statement.BaseStatementHandler.<init>(BaseStatementHandler.java:60) 71 org.apache.ibatis.executor.statement.PreparedStatementHandler.<init>(PreparedStatementHandler.java:36) 72 org.apache.ibatis.executor.statement.RoutingStatementHandler.<init>(RoutingStatementHandler.java:42) 73 org.apache.ibatis.session.Configuration.newStatementHandler(Configuration.java:348) 74 org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:43) 75 org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108) 76 org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75) 77 org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145) 78 org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:134) 79 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 80 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 81 sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 82 java.lang.reflect.Method.invoke(Unknown Source) 83 org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355) 84 com.sun.proxy.$Proxy10.insert(Unknown Source) 85 org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:237) 86 com.sinaapp.mydemo27.daoimpl.UserDaoImpl.inseartUser(UserDaoImpl.java:20) 87 com.sinaapp.mydemo27.service.UserService.insertUser(UserService.java:30) 88 com.sinaapp.mydemo27.service.UserService$$FastClassByCGLIB$$8193c93a.invoke(<generated>) 89 net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191) 90 org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688) 91 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 92 org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) 93 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 94 org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621) 95 com.sinaapp.mydemo27.service.UserService$$EnhancerByCGLIB$$3e2827df.insertUser(<generated>) 96 com.sinaapp.mydemo27.controller.UserController.handleInseart(UserController.java:55) 97 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 98 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 99 sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)100 java.lang.reflect.Method.invoke(Unknown Source)101 org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)102 org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)103 org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)104 org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)105 org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)106 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)107 org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)108 javax.servlet.http.HttpServlet.service(HttpServlet.java:641)109 javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
When you are dying, go all the way
Https://code.google.com/p/sqlite-jdbc/source/browse/src/main/java/org/sqlite/RS.java? R = e74939879270122b724d6fd62d8c40aa70870fcf
After reading the source of SQLite jdbc, only the following sentence is found. Therefore, the resultType is changed to "Object", and an error is returned.
public String getColumnClassName(int col) throws SQLException { checkCol(col); return "java.lang.Object"; }
Desperate, But I suddenly thought of having to find a new SQLite-jdbc driver on findjar.com, so
Http://www.findjar.com/index.x? Query = sqlite
The latest version"Sqlite-Jdbc-3.6.14.1.jar. "The result was amazing,
The error is no longer caused by java. SQL. SQLException: NYI,
For parameterTypeMissMatch, this will change the resultType back to int and then run again, thought it would be OK,
Unexpectedly, an error was reported again, but I know this error. The only error of the SQL primary key is that the auto-increment of SQLite ID is false, so it is not auto-incrementing. It is just a record, manually add it.
After the auto-increment is modified, the test is normal.
One word, tired, share to prevent people with the same problem from tangle here.
Spring mvc mybatis integration of the two.
No integration of mybatis
I use springmvc and mybatis. I don't know why the JSPs cannot be injected into the controller.
Check whether the submitted value is submitted through the ing of queryUserTestList and whether there are submitted values in the ing. If none of the values are submitted, or the ing you submitted is not queryUserTestList, then you certainly cannot get the value. You can use firebug, a debugging tool in the firefox browser, to check whether your submission is correct.