【MySql】数据库连接异常:The last packet sent successfully to the server was 0 milliseconds ago
2017-10-16 18:30
453 查看
使用数据库浏览工具 或 程序 连接mysql数据库遇到异常:
The last packet sent successfully to the server was 0 milliseconds ago
请检查核对:
1·修改my.ini bind-address = 127.0.0.1 为 bind-address = 0.0.0.0 使非本地网络可以访问数据库
2·检查防火墙是否有开放3306端口
3·网上广为流传的86400秒超时 回收机制 并不和我遇到的问题一致,这种问题是在程序运行过程中因为我们使用的连接池不知道连接被回收了所以报出的异常,解决方案可以是修改连接池配置或修改mysql空闲超时时间配置。
The last packet sent successfully to the server was 0 milliseconds ago
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:989) at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:341) at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2196) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2229) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2024) at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:779) at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at com.ad.MysqlDemo.main(MysqlDemo.java:32) Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211) at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300) ... 15 more Exception in thread "main" java.lang.NullPointerException at com.ad.MysqlDemo.main(MysqlDemo.java:57)
请检查核对:
1·修改my.ini bind-address = 127.0.0.1 为 bind-address = 0.0.0.0 使非本地网络可以访问数据库
2·检查防火墙是否有开放3306端口
3·网上广为流传的86400秒超时 回收机制 并不和我遇到的问题一致,这种问题是在程序运行过程中因为我们使用的连接池不知道连接被回收了所以报出的异常,解决方案可以是修改连接池配置或修改mysql空闲超时时间配置。
相关文章推荐
- mysql 连接出现The last packet sent successfully to the server was 0 milliseconds ago.问题解决
- mysql 连接池连接超时的问题(The last packet sent successfully to the server was 776,652 milliseconds ago)
- java mysql The last packet sent successfully to the server was 0 milliseconds ago.
- [Java] 解决异常:“The last packet sent successfully to the server was 0 milliseconds ago.
- The last packet sent successfully to the server was 0 milliseconds ago.[nutch---mysql ]
- [Java] 解决异常:“The last packet sent successfully to the server was 0 milliseconds ago.
- 异常The last packet sent successfully to the server was 0 millise 4000 conds ago...
- 解决异常:“The last packet sent successfully to the server was 0 milliseconds ago. ”的办法
- 两种解决异常:“The last packet sent successfully to the server was 0 milliseconds ago. ”的办法
- 两种解决异常:“The last packet sent successfully to the server was 0 milliseconds ago. ”的办法
- 两种解决异常:“The last packet sent successfully to the server was 0 milliseconds ago. ”的办法
- mysql Communications link failure Last packet sent to the server was X ms ago
- The last packet sent successfully to the server was 0 milliseconds ago问题的解决
- The last packet sent successfully to the server was 0 milliseconds ago.
- The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received
- The last packet sent successfully to the server was 0 milliseconds ago, The driver has not received
- The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. (关于jdbc)
- mysql Communications link failure Last packet sent to the server was X ms ago
- android解决The last packet sent successfully to the server was 0 milliseconds ago. The driver has not
- The last packet sent successfully to the server was 0 milliseconds ago