错误日志:
{"timestamp":1659058978622,"status":500,"error":"Internal Server Error","exception":"org.springframework.dao.RecoverableDataAccessException","message":"n### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 48,911,413 milliseconds ago. The last packet sent successfully to the server was 48,911,427 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.n### The error may exist in com/iflytek/sclass/learnenglish/mapper/EnglishDailyDicMapper.java (best guess)n### The error may involve com.iflytek.sclass.learnenglish.mapper.EnglishDailyDicMapper.selectByPhaseAndTime-Inlinen### The error occurred while setting parametersn### SQL: select a.id, a.phase_type, a.create_time , b.content, b.chinese, b.audio_url FROM english_daily_dic a LEFT JOIN english_sentence_list b ON a.sentence_id = b.id WHERe a.phase_type = ? AND a.create_time = ? limit 1n### Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 48,911,413 milliseconds ago. The last packet sent successfully to the server was 48,911,427 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.n; SQL []; The last packet successfully received from the server was 48,911,413 milliseconds ago. The last packet sent successfully to the server was 48,911,427 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either
mysql默认如果8小时没有请求的话就会断开链接。
方法一:
通过在MYSQL的JDBC连接串上加了autoReconnectForPools=true即可解决。
方法二:
通过在配置文件中dhcp部分加上如下两个参数,然后重启服务解决
testOnBorrow=”true”
validationQuery=”select 1″
方法三:
上述方法只对mysql5以前的版本生效,所以mysql5以后用下述方法
mysql﹥
mysql﹥ show global variables like ‘wait_timeout’;
±--------------±--------+
| Variable_name | Value |
±--------------±--------+
| wait_timeout | 28800 |
±--------------±--------+
1 row in set (0.00 sec)
28800 seconds,也就是8小时。
查看mysql5的手册,发现对wait_timeout的最大值分别是24天/365天(windows/linux)。以windows为例,假设我们要将其设为21天,我们只要修改mysql5的配置文件“my.ini”(mysql5 installation dir),增加一行:wait_timeout=1814400
需要重新启动mysql5。
linux系统配置文件:/etc/my.cnf
测试显示问题解决了。



