开发者社区> 问答> 正文

jfinal连接hsqldb,执行activeRecordPlugin.start()报错?报错

最近要使用junit 和dbunit做单元测试,发现使用jfinal的c3p0的时候,执行activeRecordPlugin.start()会报错。请问有人碰到这个问题吗?有啥好的 解决方法求分享一下。代码如下:

C3p0Plugin c3p0Plugin = new C3p0Plugin("jdbc:hsqldb:mem:my-project-test;shutdown=true", "", "");c3p0Plugin.start(); 
Connection connection = c3p0Plugin.getDataSource().getConnection();  
Statement statement = connection.createStatement(); 
statement.execute("CREATE TABLE users ( id INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 1), username VARCHAR(10), first_name VARCHAR(10), last_name VARCHAR(10) )"); 
statement.close();  
ActiveRecordPlugin activeRecordPlugin = new ActiveRecordPlugin(c3p0Plugin); 
activeRecordPlugin.addMapping("users", User.class); activeRecordPlugin.start();

展开
收起
爱吃鱼的程序员 2020-06-12 15:30:54 700 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    ActiveRecordPlugin脱离web使用,详见jfinal2.0手册5.12章节。

    错误信息如下:

    CannotcreateTableobject,maybethetableusersisnotexists.
    Exceptioninthread"main"com.jfinal.plugin.activerecord.ActiveRecordException:java.sql.SQLSyntaxErrorException:userlacksprivilegeorobjectnotfound:
     atcom.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:91)
     atcom.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:171)
     atdao.TestUser.main(TestUser.java:24)
     atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
     atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     atjava.lang.reflect.Method.invoke(Method.java:483)
     atcom.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
    Causedby:java.sql.SQLSyntaxErrorException:userlacksprivilegeorobjectnotfound:
     atorg.hsqldb.jdbc.JDBCUtil.sqlException(UnknownSource)
     atorg.hsqldb.jdbc.JDBCUtil.sqlException(UnknownSource)
     atorg.hsqldb.jdbc.JDBCStatement.fetchResult(UnknownSource)
     atorg.hsqldb.jdbc.JDBCStatement.executeQuery(UnknownSource)
     atcom.mchange.v2.c3p0.impl.NewProxyStatement.executeQuery(NewProxyStatement.java:35)
     atcom.jfinal.plugin.activerecord.TableBuilder.doBuild(TableBuilder.java:106)
     atcom.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:84)
     ...7more
    Causedby:org.hsqldb.HsqlException:userlacksprivilegeorobjectnotfound:
     atorg.hsqldb.error.Error.error(UnknownSource)
     atorg.hsqldb.error.Error.error(UnknownSource)
     atorg.hsqldb.ParserDQL.readTableName(UnknownSource)
     atorg.hsqldb.ParserDQL.readTableOrSubquery(UnknownSource)
     atorg.hsqldb.ParserDQL.XreadTableReference(UnknownSource)
     atorg.hsqldb.ParserDQL.XreadFromClause(UnknownSource)
     atorg.hsqldb.ParserDQL.XreadTableExpression(UnknownSource)
     atorg.hsqldb.ParserDQL.XreadQuerySpecification(UnknownSource)
     atorg.hsqldb.ParserDQL.XreadSimpleTable(UnknownSource)
     atorg.hsqldb.ParserDQL.XreadQueryPrimary(UnknownSource)
     atorg.hsqldb.ParserDQL.XreadQueryTerm(UnknownSource)
     atorg.hsqldb.ParserDQL.XreadQueryExpressionBody(UnknownSource)
     atorg.hsqldb.ParserDQL.XreadQueryExpression(UnknownSource)
     atorg.hsqldb.ParserDQL.compileCursorSpecification(UnknownSource)
     atorg.hsqldb.ParserCommand.compilePart(UnknownSource)
     atorg.hsqldb.ParserCommand.compileStatements(UnknownSource)
     atorg.hsqldb.Session.executeDirectStatement(UnknownSource)
     atorg.hsqldb.Session.execute(UnknownSource)
     ...12more

    2020-06-12 15:31:11
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载