是否有支持connectionInitSql
的PostgreSQL JDBC驱动程序,可以与hikari一起使用?
我看过以下内容:
https://jdbc.postgresql.org/ https://github.com/pgjdbc/pgjdbc
但他们都不支持。
代码:
HikariConfig config = new HikariConfig();
config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
config.addDataSourceProperty("connectionInitSql", "SET ROLE admin");
HikariDataSource hikariDataSource = new HikariDataSource(config)
错误:
Exception in thread "main" java.lang.RuntimeException: Property connectionInitSql does not exist on target class org.postgresql.ds.PGSimpleDataSource
at com.zaxxer.hikari.util.PropertyElf.setProperty(PropertyElf.java:131)
at com.zaxxer.hikari.util.PropertyElf.lambda$setTargetFromProperties$0(PropertyElf.java:57)
at java.util.Hashtable.forEach(Hashtable.java:878)
at com.zaxxer.hikari.util.PropertyElf.setTargetFromProperties(PropertyElf.java:52)
at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:331)
at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:109)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:108)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
答案 0 :(得分:0)
我已经弄清楚了我的问题。使用
设置connectionInitSql
config.setConnectionInitSql()