背景
使用springboot框架/mbs,今早看日志发现存在dao.RecoverableDataAccessException 问题;.
下面展示一些 内联代码片
。
2022-06-23 03:17:21,806 ERROR com.example.jmindex.controller.getDataFromInternet.getJm.getEtcJm [http-nio-8083-exec-10] org.springframework.dao.RecoverableDataAccessException:
### Error querying database. Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: The last packet successfully received from the server was 3,609,285 milliseconds ago. The last packet sent successfully to the server was 3,622,297 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里添加 autoReconnect=true;
#本地数据库链接
url: jdbc:mysql://localhost:3306/try?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8