Springboot提示数据库连接问题Connection is not available

2019/05/30 14:40
阅读数 4.2K
2019-05-29 11:19:51.824 WARN 854 --- [io-8080-exec-10] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: null

2019-05-29 11:19:51.825 ERROR 854 --- [io-8080-exec-10] o.h.engine.jdbc.spi.SqlExceptionHelper : HikariPool-1 - Connection is not available, request timed out after 30004ms.
2019-05-29 11:19:51.844 ERROR 854 --- [io-8080-exec-10] o.s.b.w.servlet.support.ErrorPageFilter : Forwarding to error page from request [/aa/bb] due to exception [Unable to acquire JDBC Connection; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection]

org.springframework.dao.DataAccessResourceFailureException: Unable to acquire JDBC Connection; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:238) ~[spring-orm-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:225) ~[spring-orm-5.0.8.RELEASE.jar:5.0.8.RELEASE]

 

百度后,尝试了很多方法,包括修改数据库的超时时间:

mysql> set global wait_timeout=28800;
Query OK, 0 rows affected
mysql> show global variables like 'wait_timeout';

包括设置参数:

spring.datasource.hikari.read-only=false
spring.datasource.hikari.connection-timeout=60000
spring.datasource.hikari.idle-timeout=60000
spring.datasource.hikari.validation-timeout=3000
spring.datasource.hikari.max-lifetime=60000
spring.datasource.hikari.login-timeout=5
spring.datasource.hikari.maximum-pool-size=60
spring.datasource.hikari.minimum-idle=10

多种方法后,发现可能还是需要在pom.xml文件中添加参数配置可能解决此问题。

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部