mysql重连,连接丢失:The last packet successfully received from the server-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

mysql重连,连接丢失:The last packet successfully received from the server

jianjob 2016-02-25 15:00:12 25850

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 20,820,001 milliseconds ago. The last packet sent successfully to the server was 20,820,002 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.at sun.reflect.GeneratedConstructorAccessor29.newInstance(Unknown Source) ~[na:na]at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_51]at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_51]at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[mysql-connector-java-5.1.29.jar:na]at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1129) ~[mysql-connector-java-5.1.29.jar:na]at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3988) ~[mysql-connector-java-5.1.29.jar:na]at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2598) ~[mysql-connector-java-5.1.29.jar:na]at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778) ~[mysql-connector-java-5.1.29.jar:na]at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2828) ~[mysql-connector-java-5.1.29.jar:na]at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:5372) ~[mysql-connector-java-5.1.29.jar:na]at com.mchange.v2.c3p0.impl.NewProxyConnection.setAutoCommit(NewProxyConnection.java:881) ~[c3p0-0.9.1.1.jar:0.9.1.1]at org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler.setAutoCommit(AttributeRestoringConnectionInvocationHandler.java:98) ~[quartz-2.2.1.jar:na]

关系型数据库 MySQL
分享到
取消 提交回答
全部回答(3)
  • wq_crazyboy
    2019-07-17 18:30:42

    建议楼主可以参考下下面的链接逐项排查下您的客户端的设置:https://help.aliyun.com/knowledge_detail/6527054.html

    0 0
  • 阿乐轩
    2019-07-17 18:30:42

    这种排查思路一般是看排除法,如果web和DB不在一个机器上,可以先用客户端工具去连接数据库看看是否正常,如果正常则可以在服务器上telnet下DB的端口看看是否畅通,也可以写一个简单的测试数据库连接的代码测试webserver和DBserver通讯是否正常。如果都正常了,则从webserver上看看,如看看系统日志是否可能有oom等情况,

    0 0
  • 蔷薇管理器
    2019-07-17 18:30:42

    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 20,820,001 milliseconds ago. The last packet sent successfully to the server was 20,820,002 milliseconds ago. is longer than the server configured value of 'wait_timeout'.

    一般是数据库就没连上
    1.检查下数据库连接信息,看连接是否通,数据库url是否正确
    2.检查账号密码是否正确
    3.查看数据库是否宕机
    4.在出问题的机器上,使用命令行模式尝试是否能连接上

    0 0
添加回答
数据库
使用钉钉扫一扫加入圈子
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

推荐文章
相似问题