wuqingvika 发表于 2023-11-8 15:49

mysql连接超时报错

The last packet successfully received from the server was 14,929 milliseconds ago. The last packet sent successfully to the server was 14,930 milliseconds ago.


The last packet successfully received from the server was 14,929 milliseconds ago. The last packet sent successfully to the server was 14,930 milliseconds ago.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
        at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
        at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
        at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
        at com.mysql.cj.protocol.a.NativeProtocol.readMessage(NativeProtocol.java:520)
        at com.mysql.cj.protocol.a.NativeProtocol.checkErrorMessage(NativeProtocol.java:700)
        at com.mysql.cj.protocol.a.NativeProtocol.sendCommand(NativeProtocol.java:639)
        at com.mysql.cj.protocol.a.NativeProtocol.sendQueryPacket(NativeProtocol.java:987)
        at com.mysql.cj.NativeSession.execSQL(NativeSession.java:666)
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:930)
        ... 62 common frames omitted
Caused by: java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)

怎么延长这个时间呢 。。不知道配置啥属性,求大佬帮忙解答下





连晋 发表于 2023-11-8 15:58

呐拿去

https://www.bmabk.com/index.php/post/106031.html

实际上就是 给 阿里巴巴的连接池增加一个 查询的sql让他定期去查一次数据库,这样你数据库连接最少就能有是存活状态,这样他就不会死了

Protoss_krz 发表于 2023-11-8 18:09

你这不是超时,是长时间没连接,这条链接已经断掉了。实际按楼上给的方案,修改下Druid的配置让它自己定期清理下连接池里面的过期链接就行了

CNASA 发表于 2023-11-8 20:07

Mr.[先知] 发表于 2023-11-8 20:09

这个不是超时了,是长时间没有用mysql 连接被mysql服务器断开了
具体参考楼上

sai609 发表于 2023-11-8 20:54

点击连接,设置最小时为5秒,次数不限

alphagis 发表于 2023-11-9 08:45

学习到了

Qvv1koa 发表于 2023-11-21 09:39

参考楼上,比较好奇的是啥项目长时间没连接,自己能断掉?
页: [1]
查看完整版本: mysql连接超时报错