Last packet sent to the server was 0 ms ago.
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Last packet sent to the server was 0 ms ago.相关的知识,希望对你有一定的参考价值。
ERROR JDBCExceptionReporter:101 - Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: Connection reset by peer: socket write error
STACKTRACE:
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
at java.io.BufferedOutputStream.flush(Unknown Source)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2739)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2650)
** END NESTED EXCEPTION **
Last packet sent to the server was 0 ms ago.
16:00:00,197 ERROR JDBCExceptionReporter:101 - Already closed.
16:00:00,197 ERROR JDBCExceptionReporter:101 - Already closed.
16:00:00,200 ERROR JDBCExceptionReporter:101 - Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
长时间未操作,就会报该错;百度了许多,说是把wait_timeout改为10年,觉得这个方法不敢恭维;
autoReconnect=true,不起作用;求解!!!
odbc的错误 应该就是数据库的原因了 请规范数据库操作
每次打开就要记得关掉追问
不是哦,是连接超时,mysql的默认连接是8小时,过了8小时就会报这个错。。。
追答没错啊 就是因为你的连接一直开着~~~需要读取或者写入再去打开数据库
参考技术A 看看是不是端口的问题。我在项目启动遇到同样问题。原来在项目中配置URL时没有写端口,而启动端口由3306变成3307,导致错误。 参考技术B ERROR JDBCExceptionReporter:101 - Communications link failure due to underlying exception:** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: Connection reset by peer: socket write error
STACKTRACE:
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
at java.io.BufferedOutputStream.flush(Unknown Source)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2739)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2650)
** END NESTED EXCEPTION **
Last packet sent to the server was 0 ms ago.
16:00:00,197 ERROR JDBCExceptionReporter:101 - Already closed.
16:00:00,197 ERROR JDBCExceptionReporter:101 - Already closed.
16:00:00,200 ERROR JDBCExceptionReporter:101 - Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received(
载自:https://blog.csdn.net/ponxbin/article/details/80608040
关于版本比较新的数据库(Mysql8.0)连接的问题:
he last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:172)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at mysqlconnect.connect.main(connect.java:24)
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: 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.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:59)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:103)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:149)
at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:165)
at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:355)
at com.mysql.cj.protocol.a.NativeAuthenticationProvider.negotiateSSLConnection(NativeAuthenticationProvider.java:789)
at com.mysql.cj.protocol.a.NativeAuthenticationProvider.proceedHandshakeWithPluggableAuthentication(NativeAuthenticationProvider.java:499)
at com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:217)
at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1411)
at com.mysql.cj.NativeSession.connect(NativeSession.java:165)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:982)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:852)
... 6 more
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
at sun.security.ssl.Handshaker.processLoop(Unknown Source)
at sun.security.ssl.Handshaker.process_record(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:213)
at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:206)
at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99)
at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:350)
... 13 more
Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
at com.mysql.cj.protocol.ExportControlled$X509TrustManagerWrapper.checkServerTrusted(ExportControlled.java:280)
at sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(Unknown Source)
... 25 more
Caused by: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
at sun.security.provider.certpath.PKIXCertPathValidator.validate(Unknown Source)
at sun.security.provider.certpath.PKIXCertPathValidator.engineValidate(Unknown Source)
at java.security.cert.CertPathValidator.validate(Unknown Source)
at com.mysql.cj.protocol.ExportControlled$X509TrustManagerWrapper.checkServerTrusted(ExportControlled.java:273)
... 26 more
Exception in thread "main" java.lang.NullPointerException
at mysqlconnect.connect.main(connect.java:34)
网上说的什么修改的方法对我没有用
诸如此类:
1·修改my.ini bind-address = 127.0.0.1 为 bind-address = 0.0.0.0 使非本地网络可以访问数据库
2·检查防火墙是否有开放3306端口
3·网上广为流传的86400秒超时 回收机制 并不和我遇到的问题一致,这种问题是在程序运行过程中因为我们使用的连接池不知道连接被回收了所以报出的异常,解决方案可以是修改连接池配置或修改mysql空闲超时时间配置。
以上方法均没用,主要是mysql和驱动版本的问题
我的mysql是8.0,驱动也是8.x最新的;
Class.forName("com.mysql.cj.jdbc.Driver");
url = "jdbc:mysql://localhost:3306/jnditest?serverTimezone=GMT&useSSL=false";//数据库的路径
主要是红色字体方面,serverTimezone缺失是很容易从错误找出来的,但是重点是useSSL=false,这个从错误提示是看不出来的,它有个很重要的作用是使用JDBC跟你的数据库连接的时候,你的JDBC版本与MySQL版本不兼容,MySQL的版本更高一些,在连接语句后加上“useSSL=‘true’” ,就可以连接到数据库了。更高版本。但如果是兼容版本的话就会出错。
我试了改成true的确又出现了这个问题。
————————————————
版权声明:本文为CSDN博主「重新学习java」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/ponxbin/article/details/80608040
以上是关于Last packet sent to the server was 0 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.
Springboot项目启动:报错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
MysqlCommunications link failure,The last packet sent successfully to the server was 0 millisecond
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received