1 java.sql.SQLException: NYIhtml
2 org.sqlite.RS.getColumnClassName(RS.java:269)java
在配置mybatis+springmvc+sqlite時候,web
<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 不會自動加1,因此手動了 </selectKey> insert into t_demo (id,name,age,sex)values(#{id},#{name},#{age},#{sex}) </insert>
遭遇到一下問題: spring
1 root causesql
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 causeapache
java.sql.SQLException: NYI org.sqlite.RS.getColumnClassName(RS.java:269)
由於網上關於SQLite的整合資料較少(什麼百度 谷歌,搜遍了,連mybatis官網的例子都看了),因此本身就折騰,大概有4天吧,天天看到這個錯誤,已經不煩了,已經到快吐了。session
在配置mybatis的mapper.xml中須要配置 insert語句,而ID自增是最大的問題,PostgreSQL版的我已經搞定,想着mybatis
SQLite應該相似,結果始終是報錯,具體:mvc
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)
快心死的時候,都去app
https://code.google.com/p/sqlite-jdbc/source/browse/src/main/java/org/sqlite/RS.java?r=e74939879270122b724d6fd62d8c40aa70870fcf
看了SQLite jdbc的source,結果只發現下面這句,因而把resultType類型改爲 「Object」,結果仍是報錯。
public String getColumnClassName(int col) throws SQLException { checkCol(col); return "java.lang.Object"; }
絕望了,不過 忽然想到 要不要去 findjar.com上找個新的SQLite-jdbc 驅動,因而
http://www.findjar.com/index.x?query=sqlite
找到了最新版本「 sqlite-jdbc-3.6.14.1.jar」 結果使人驚喜的事發生了,
報錯再也不是java.sql.SQLException: NYI,
換 parameterTypeMissMatch,這個把resultType類型改回去int,再跑,覺得會ok,
出人意料的是,又報錯,不過這個錯我是知道的,sql主鍵惟一的錯誤,原來SQLite的ID自增是假的,就不自增,只是記錄而已,要本身手動加。
修改自增後,測試沒有問題了。
一個字,心累,share防止有一樣問題的人在此糾結。
若轉載請標註 :轉自 博客園 : http://www.cnblogs.com/rojas/p/4001510.html