获取 Hikari 池初始化错误

Getting a Hikari Pool Initialization error

在我的 JRE 11 中启动时得到这个。团队中似乎没有其他人得到它。如果我在 JDK 8.

中编译和 运行 它确实解决了
HikariPool-1 - Exception during pool initialization

java.nio.BufferOverflowException: null
    at java.base/java.nio.HeapByteBuffer.put(HeapByteBuffer.java:221)
    at java.base/java.nio.ByteBuffer.put(ByteBuffer.java:978)
    at oracle.net.ano.AnoCommNIO.d(Unknown Source

等等

2021-09-22 12:13:23.280  WARN [amp-optimizer-services,,] 29760 --- [-172.28.233.166] o.s.b.a.jdbc.DataSourceHealthIndicator   : DataSource health check failed

com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: null
    at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:595)
    at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:581)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)

我遇到了同样的问题,但 Java 8 以及 Java 11。我尝试传递这个 VM 参数,它对我有用:

-Doracle.jdbc.javaNetNio=假

或者,如果创建 OracleDataSource,我们也可以将其设置为属性:

OracleDataSource oracleDataSource = new OracleDataSource();
oracleDataSource.setURL(jdbcUrl);
oracleDataSource.setDriverType(dbDriver);
Properties properties = new Properties();
//... other properties if needed
properties.setProperty("oracle.jdbc.javaNetNio", "false");
    
oracleDataSource.setConnectionProperties(properties);

或者如果创建一个 HikariDataSource,我们可以将其用作:

HikariConfig poolConfig = new HikariConfig();
poolConfig.setJdbcUrl(jdbcUrl);
poolConfig.setDriverClassName(jdbcDriver);  
//...  other properties if needed
poolConfig.addDataSourceProperty("oracle.jdbc.javaNetNio", "false");