1

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?

Charlie
  • 3,113
  • 3
  • 38
  • 60
  • Does this answer your question? [attempt to reconnect jdbc pool datasource after database restarts](https://stackoverflow.com/questions/11301707/attempt-to-reconnect-jdbc-pool-datasource-after-database-restarts) – SMor Jun 29 '21 at 02:53
  • Nope. I already checked that question and answer. I checked other similar questions but no solution has helped me yet – Charlie Jun 29 '21 at 03:07

1 Answers1

0

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
Charlie
  • 3,113
  • 3
  • 38
  • 60