ActiveRecordPlugin与 PostgreSQL 数据库兼容有bug

ActiveRecordPlugin 不能使用 PostgreSQL  数据库兼容有bug,无法正常使用。求助有解决办法吗?

关键代码

testdb {
    main(String[] args) {
    
        DruidPlugin dp = DruidPlugin(, , );
        ActiveRecordPlugin arp = ActiveRecordPlugin(dp);
        arp.addMapping(, LiangjianUser.);

        dp.start();
        arp.start();
        System..println();
    }
}

报错信息

com.lj.hikvision.service.testdb

12:48:12.664 [main] INFO com.alibaba.druid.pool.DruidDataSource - {dataSource-1} inited

Can not create Table object, maybe the table liangjiantable is not exists.

Exception in thread "main" com.jfinal.plugin.activerecord.ActiveRecordException: org.postgresql.util.PSQLException: ERROR: syntax error at or near "`"

  位置:15

at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:55)

at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:226)

at com.lj.hikvision.service.testdb.main(testdb.java:34)

Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "`"

  位置:15

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2477)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2190)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:300)

at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428)

at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354)

at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:301)

at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:287)

at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:264)

at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:231)

at com.alibaba.druid.pool.DruidPooledStatement.executeQuery(DruidPooledStatement.java:297)

at com.jfinal.plugin.activerecord.TableBuilder.doBuild(TableBuilder.java:71)

at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:47)

... 2 more


进程已结束,退出代码 1


错误定位 是 执行 arp.start(); 后报错  Can not create Table object, maybe the table liangjiantable is not exists. 

表在数据库里是有的 并且直接使用jdbc连接 测试是 好的,所以估计是ActiveRecordPlugin 。

直接使用.png

此程序连接mysql 是好的 就是连接PostgreSQL  数据库报错,求助有解决办法吗?我换了几个低版本的也报同样的错

jar版本.png


评论区

apachelj

2020-07-11 13:17

url 和字符串的内容在上面不显示

apachelj

2020-07-11 13:19

补充 DruidPlugin dp = new DruidPlugin("jdbc:postgresql://127.0.0.1:5432/liangjiandb", "postgres", "123456");

ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
arp.addMapping("liangjiantable", LiangjianUser.class);

杜福忠

2020-07-11 13:52

https://jfinal.com/doc/5-9
// 配置Postgresql方言
arp.setDialect(new PostgresqlDialect());

apachelj

2020-07-11 15:24

多谢 已配置 搞定 arp.setDialect(new PostgreSqlDialect()); 多谢

热门分享

扫码入社