【发布时间】:2021-02-06 11:45:55
【问题描述】:
我在 stackoverflow 中阅读了很多关于此主题的问题,并在我的 application-prd.properties 中以以下代码结束:
#PRD IP
spring.datasource.url=
spring.datasource.username=
spring.datasource.password=
# Fix for DB Connection
spring.datasource.tomcat.max-active=10
spring.datasource.tomcat.initial-size=5
spring.datasource.tomcat.max-idle=5
spring.datasource.tomcat.min-idle=1
spring.datasource.tomcat.test-while-idle=true
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.validation-query=SELECT 1 FROM DUAL
spring.datasource.tomcat.time-between-eviction-runs-millis=5000
spring.datasource.tomcat.min-evictable-idle-time-millis=60000
#Error fix for JSON conversion
spring.jackson.parser.allow-unquoted-control-chars=true
但是,由于某种原因,我的 Spring 应用程序的 Tomcat 突然失去了与数据库的连接,出现以下错误:
Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
我不知道该怎么办。我已经为此苦苦挣扎了好几个星期。还有什么我可以做的吗?或者我可以说这是防火墙问题,基础架构团队应该检查一下吗?
谢谢
【问题讨论】:
-
你能用任何数据库客户端工具连接数据库吗?像 datastudio 或 mysql 客户端。另外,如果您有 IP,请尝试 ping url。
-
只有重启tomcat才能重新连接。
-
您是否尝试增加连接池大小?如果增加尺寸会怎样?
标签: java spring spring-boot tomcat