“RecoverableDataAccessException"的原因是什么?检查数据库健康时收到? [英] What is the cause of "RecoverableDataAccessException" received when checking health of database?

查看:136
本文介绍了“RecoverableDataAccessException"的原因是什么?检查数据库健康时收到?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 spring-boot 和 oracle 数据库.

I am using spring-boot along with oracle database.

在访问 http://localhost:8888/health 健康端点时,我得到以下响应:

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"}

在搜索上述问题的详细信息时,我找到了这个链接 https://github.com/spring-projects/spring-boot/issues/1303.它详细描述了问题,但非常简短地提到了解决部分.

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?

推荐答案

需要配置Tomcat JDBC连接池来测试连接.这应该可以防止数据库运行状况指示器因连接断开而卡住.

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.

您可以通过向 application.properties 添加一些配置来实现.例如:

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

这篇关于“RecoverableDataAccessException"的原因是什么?检查数据库健康时收到?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆