@Test public void queryD(){ DruidPlugin dp = new DruidPlugin("jdbc:sqlite::resource:db/acc.db", "userName", "password"); ActiveRecordPlugin arp = new ActiveRecordPlugin(dp); // 加载数据库与Model对应 // _MappingKit.mapping(arp); arp.addMapping("a","aid", A.class); arp.setDialect(new Sqlite3Dialect()); dp.start(); arp.start(); A a = new A(); a.set("aid",1); a.set("bid",1); a.set("cid",1); a.save(); }
数据库结构如下:
调用save()进行保存数据的时候,提示:
com.jfinal.plugin.activerecord.ActiveRecordException: java.sql.SQLFeatureNotSupportedException: not implemented by SQLite JDBC driver at com.jfinal.plugin.activerecord.Model.save(Model.java:612) at TestDb.queryD(TestDb.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55) Caused by: java.sql.SQLFeatureNotSupportedException: not implemented by SQLite JDBC driver at org.sqlite.jdbc3.JDBC3PreparedStatement.unsupported(JDBC3PreparedStatement.java:448) at org.sqlite.jdbc3.JDBC3Statement.getGeneratedKeys(JDBC3Statement.java:357) at com.alibaba.druid.pool.DruidPooledStatement.getGeneratedKeys(DruidPooledStatement.java:760) at com.jfinal.plugin.activerecord.dialect.Dialect.getModelGeneratedKey(Dialect.java:157) at com.jfinal.plugin.activerecord.Model.save(Model.java:608) ... 25 more
是我使用方式不对吗 @
还有一个解决办法是,先不管 jfinal 这边, 先用纯 JDBC 将 sqlite 跑起来,然后用跑起来的配置用于 jfinal 配置
因为 jfinal 底层就是用的 JDBC, 仅仅对 JDBC 做了极薄封装,所以,能在 JDBC 上用的配置就一定能在 jfinal 中用