com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 45,079,583 milliseconds ago. The last packet sent successfully to the server was 45,079,583 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.
8个小时候myqsl数据库断连接了,mysql5.7,我用的,autoReconnect=true这种方式没有用了,用了druid的数据源,mysql数据库默认超时时间8小时,配置如下:
druid:
# 下面为连接池的补充设置,应用到上面所有数据源中
# 初始化大小,最小,最大
initial-size: 10
min-idle: 10
max-active: 500
# 配置获取连接等待超时的时间
max-wait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
time-between-eviction-runs-millis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
#是否自动回收超时连接
remove-abandoned: false
#超时时间(以秒数为单位)
remove-abandoned-timeout: 1800
async-init: true
time-between-connect-error-millis: 3000
log-abandoned: true
请大神指教一下,怎么设置才能其效果,我个人理解即使设置了定时检查连接是否断开,测试的时候测到断开连接,他会自动打开新的连接吗,因为效果是,有的请求没问题,有的有问题,感觉出问题的连接还存在,没有被杀掉,请大神指教一下,谢谢