I am using Spring Boot with Spring Data JPA to query database through Repository. If the backend database is booted for some reason, then Spring Boot cannot connect to that database again unless rebooted. Is there a way to get the Data JPA to repopulate connections to database after DB reboot?
Asked
Active
Viewed 1,247 times
1
-
Configure your connection pool accordingly. – M. Deinum May 27 '16 at 10:06
-
Try this post http://stackoverflow.com/questions/22684807/spring-boot-jpa-configuring-auto-reconnect might be useful – Clement Amarnath May 27 '16 at 10:15
-
I recommend you to use HikariCP. Read this https://github.com/brettwooldridge/HikariCP/wiki/Bad-Behavior:-Handling-Database-Down – Sergey Bulavkin May 27 '16 at 16:26
1 Answers
2
In Spring Boot, we can solve this problem adding these configurations in the application.properties file:
spring.datasource.testWhileIdle = true
spring.datasource.timeBetweenEvictionRunsMillis = 60000
spring.datasource.validationQuery = SELECT 1
Checkout the full explanation here

inafalcao
- 1,415
- 1
- 11
- 25