I use spring boot 2 with Hikari
connection pool, jpa and postgres.
Is there any reason to continue to use theses options
spring.datasource.testOnBorrow=true
spring.datasource.validationQuery=SELECT 1
spring.datasource.testWhileIdle
No, They are unknown properties to Hikari connection pool so no need ,
They exists only in Tomcat JDBC Connection Pool (used in old Spring boot) which you aren't using anymore.
Explanation of different between properties
DBCP testOnBorrow=false rollbackOnReturn=false enableAutoCommitOnReturn=false
Issues:
testOnBorrow=false increases the likelihood of broken connections given to your application rollbackOnReturn=false + enableAutoCommitOnReturn=false, like the C3P0 "remediation" above can bleed transactions between consumers or cause locks to be held for extended periods
HikariCP Differentiators
Tests connections with isValid() before returning them from the pool, with an optimization that bypasses the check if the connection was utilized within the last 1000ms Tracks connection state (and transaction state), and performs rollback() only the the case of a non-autocommit connections with uncommitted changes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With