HikariPool-1 - Failed to validate connection org.postgresql.jdbc.PgConnection@2a84e649 (This connection has been closed.)

kj007

In Spring Boot 2.x, Hikari is default connection pool so if you have JPA then you don't need to add Hikari dependency in pom but if you want to use dbcp2 then you need to exclude Hikari and add dbcp2 dependency.

So in your case you mixed settings for both.

if just would like to stay with Hikari then remove dbcp2 dependencies and change your data source properties to use spring.datasource.hikari.

Add below properties to validate connection:

spring.datasource.testWhileIdle=true
spring.datasource.test-on-borrow=true

To further check if there is any leak, please add below properties and check how goes your pool connection and if there is any leak.

spring.datasource.hikari.leakDetectionThreshold=2000
logging.level.com.zaxxer.hikari=DEBUG