0

We have an issue with the connection of DB being lost when the DB server is getting restarted. We are using DBCP for the connection pool. We used autoReconnect=true which seems to solve this problem, but it is not recommended. Could anyone please suggest a suitable alternative for autoReconnect. We are already using testOnBorrow=true and validationQuery=SELECT 1. Thanks for your help!!

Tried autoReconnect=true, testOnBorrow=ture and validationQuery=SELECT 1. Want an alternative to autoReconnect=true since it is not recommended.

Naren
  • 1
  • 1
  • https://stackoverflow.com/questions/53077180/springboot-application-fails-on-db-restart – kabinarayan dalei Feb 27 '23 at 11:08
  • Hi @kabinarayandalei, I am already using type=javax.sql.DataSource, I guess that should be fine right? – Naren Feb 27 '23 at 12:36
  • Note that the use of autoReconnect is not recommended: The use of this feature is not recommended, because it has side effects related to session state and data consistency when applications don't handle SQLExceptions properly, and is only designed to be used when you are unable to configure your application to handle SQLExceptions resulting from dead and stale connections properly. Can you please try with spring.datasource.tomcat.testOnBorrow=true spring.datasource.tomcat.validationQuery=SELECT 1 and tamcat datasource – kabinarayan dalei Mar 13 '23 at 10:14

0 Answers0