Priya R
Priya R

Reputation: 451

How to prevent failure on Hikari Pool initialization if database connection fails

I have a project which uses Hikari Connection Pool. I create connection pool for all the databases one by one as new HikariDataSource(someConfig)

This works fine when all the databases are available. But if any of the database is offline the Play project gives the below error:

[RuntimeException: java.lang.ExceptionInInitializerError]

I do not want the application to crash if just a few of the databases are offline.

How can I avoid this error from crashing the application?

Note: I am using HikariCP package on its own in another subproject. I am not using play-hikari plugin.

Upvotes: 3

Views: 8462

Answers (1)

Nitin
Nitin

Reputation: 1660

set hikaricp property initializationFailFast=false. its description from hikaricp site:

This property controls whether the pool will "fail fast" if the pool cannot be seeded with initial connections successfully. If you want your application to start even when the database is down/unavailable, set this property to false. Default: true

Upvotes: 9

Related Questions