6

We are using SpringBoot 2.1.x version so Hikari is the default DataSource implementation. However, I am not sure how to configure Hikari settings to auto reconnect to our Oracle database after database maintenance/restart or network connection issue.

We have the following hikari settings but it does not seem to help.

account.datasource.url: jdbc:oracle:thin:@myserver:1521:DEV
account.datasource.username: user
account.datasource.password: xxxx
account.datasource.driverClassName: oracle.jdbc.driver.OracleDriver

account.datasource.hikari.connection-timeout: 30000
account.datasource.hikari.maximum-pool-size: 3
account.datasource.hikari.idle-timeout: 60000
account.datasource.hikari.max-lifetime: 1800000
account.datasource.hikari.minimum-idle: 2

It failed to reconnect after network connection to the database got restored.

Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30033ms.

Any other account.datasource.hikari.xxxxx will help to auto reconnect to the database ?

user1747980
  • 245
  • 1
  • 4
  • 14

1 Answers1

4

From the HikariCP docs:

connectionTestQuery

If your driver supports JDBC4 we strongly recommend not setting this property. This is for "legacy" drivers that do not support the JDBC4 Connection.isValid() API. This is the query that will be executed just before a connection is given to you from the pool to validate that the connection to the database is still alive. Again, try running the pool without this property, HikariCP will log an error if your driver is not JDBC4 compliant to let you know. Default: none

So I'd suggest verifying that your JDBC Driver is actually JDBC4 compliant. If it's not - set the above property.

Catchwa
  • 5,845
  • 4
  • 31
  • 57
  • 2019-07-19 08:26:24.158 --- com.zaxxer.hikari.HikariDataSource: HikariPool-1 - Starting... 2019-07-19 08:26:24.161 --- com.zaxxer.hikari.util.DriverDataSource: Registered driver with driverClassName=oracle.jdbc.driver.OracleDriver was not found, trying direct instantiation. 2019-07-19 08:26:25.375 --- com.zaxxer.hikari.pool.PoolBase: HikariPool-1 - Driver does not support get/set network timeout for connections. (oracle.jdbc.driver.T4CConnection.getNetworkTimeout()I) 2019-07-19 08:26:25.430 --- com.zaxxer.hikari.HikariDataSource: HikariPool-1 - Start completed. – user1747980 Jul 19 '19 at 16:03
  • Thanks. I see no error in the log so JDBC 4 complaint , right ? – user1747980 Jul 19 '19 at 16:11
  • We found out the problem our re-connecting issue. The above setting actually took care of the auto reconnecting. However, we have a network server issue internally that caused various issues including the reconnecting one. Good job Hikari data source. – user1747980 Jul 21 '19 at 06:25