How to overcome org.springframework.dao.RecoverableDataAccessException?

I keep getting connectivity issues when connecting my Spring project to MySQL server. I tried various tricks that I found online, but to no avail. I need help to avoid this difficulty. I put my Spring settings below and a stack trace.

Spring Settings

spring.datasource.tomcat.initialize=true
spring.dataSource.tomcat.url=jdbc:mysql://nope/canttellyou?
autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
spring.dataSource.tomcat.username=nope
spring.dataSource.tomcat.password=sorry
spring.dataSource.tomcat.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.validation-query=SELECT 1 
spring.datasource.tomcat.log-validation-errors=true

Stacktrace

stackTrace: org.springframework.dao.RecoverableDataAccessException: 
PreparedStatementCallback; SQL [select catname from animals]; The last 
packet successfully received from the server was 52,962,310 
milliseconds ago.  The last packet sent successfully to the server was 
52,962,310 milliseconds ago. is longer than the server configured value 
of 'wait_timeout'. You should consider either expiring and/or testing 
connection validity before use in your application, increasing the 
server configured values for client timeouts, or using the Connector/J 
connection property 'autoReconnect=true' to avoid this problem.; nested 
exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 
The last packet successfully received from the server was 52,962,310 
milliseconds ago.  The last packet sent successfully to the server was 
52,962,310 milliseconds ago. is longer than the server configured value 
of 'wait_timeout'. You should consider either expiring and/or testing 
connection validity before use in your application, increasing the 
server configured values for client timeouts, or using the Connector/J 
connection property 'autoReconnect=true' to avoid this problem.
+4
source share
1 answer

I have the same problem. I think the configuration setting we want to enable is:

testWhileIdle

Below is the corresponding tomcat connection pool

I will not know until tomorrow if this will work for me.

0

Source: https://habr.com/ru/post/1675357/


All Articles