What is the cause of “RecoverableDataAccessException” received when checking health of database?

我怕爱的太早我们不能终老 提交于 2019-12-05 00:16:51

问题


I am using spring-boot along with oracle database.

On accessing http://localhost:8888/health health end-point, I get following response:

{"status":"DOWN","error":"org.springframework.dao.RecoverableDataAccessException: ConnectionCallback; SQL []; Closed Connection; nested exception is java.sql.SQLRecoverableException: Closed Connection"}

While searching for the above issue details, I found this link https://github.com/spring-projects/spring-boot/issues/1303. It describes the issue in detail but it has very brief mention the resolution part.

As we can see at the above mentioned source that it is an issue in new state. Once I observed that even though this exception was returned in response, application continued to insert records into database.

How can we resolve above exception and what are its impacts on the boot application which is running?


回答1:


You need to configure the Tomcat JDBC connection pool to test connections. This should prevent the DB health indicator from being left stuck with a broken connection.

You can do so by adding some configuration to application.properties. For example:

spring.datasource.test-on-borrow: true
spring.datasource.validation-query: SELECT 1 FROM DUAL
spring.datasource.log-validation-errors: true


来源:https://stackoverflow.com/questions/27058614/what-is-the-cause-of-recoverabledataaccessexception-received-when-checking-hea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!