I have a Spring Boot (1.5.17) web application with Tomcat JDBC connection pool (8.5.34) configured as follows:
primary.datasource.tomcat.testOnBorrow=true
primary.datasource.validationQuery=SELECT 1
primary.datasource.validationInterval=35000
primary.datasource.initial-size=10
primary.datasource.max-active=50
primary.datasource.max-idle=20
primary.datasource.min-idle=10
Now if I restart the database server (SQL Server) I get the com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed
exception and the connection pool does not recover.
So what am I doing wrong?
I have found the error. I made a mistake while writing the configuration key primary.datasource.tomcat.testOnBorrow
. It should be primary.datasource.testOnBorrow
. And now it is working fine. The connection pool recovers almost immediately after database server restarts.
Here is my final configuration for anyone if they are having similar problems.
primary.datasource.testOnBorrow=true
primary.datasource.validationQuery=SELECT 1
primary.datasource.validationInterval=55000
primary.datasource.initial-size=5
primary.datasource.min-idle=5
primary.datasource.max-idle=10
primary.datasource.max-active=20
primary.datasource.removeAbandoned=true