我有一个连接到MySql数据库的spring启动应用程序。 我每天都有两份工作,早上12点和早上6点。两者都从mysql db。
获取数据问题是,几乎每天,在运行弹簧作业时,我都会丢失与数据库的连接,并出现以下错误:
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 65,098,262 milliseconds ago. The last packet sent successfully to the server was 65,098,264 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.
到目前为止我尝试了什么:
我在application.properties中添加了:
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.validation-query=Select 1
在< spring.datasource.url'我添加了autoReconnect = true和/或autoReconnectForPools = true
但没有好结果..
请你帮我一个想法来避免这种情况吗? 谢谢。