Caused by: java.io.EOFException: SSL peer shut down incorrectly

Caused by: java.io.EOFException: SSL peer shut down incorrectly_第1张图片

 Caused by: java.io.EOFException: SSL peer shut down incorrectly_第2张图片

详细报错信息如下:

2022-03-07 11:29:33.123 ERROR 70700 --- [eate-1250315597] com.alibaba.druid.pool.DruidDataSource   : create connection SQLException, url: jdbc:mysql://xxxxxxxxx:3307/xxxxx?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT, errorCode 0, state 08S01

com.mysql.cj.jdbc.exceptions.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 com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:829) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:449) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:242) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1652) ~[druid-1.2.3.jar:1.2.3]
    at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1718) ~[druid-1.2.3.jar:1.2.3]
    at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2785) ~[druid-1.2.3.jar:1.2.3]
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) ~[na:1.8.0_321]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_321]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_321]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_321]
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:317) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:204) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1369) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.NativeSession.connect(NativeSession.java:133) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:949) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:819) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    ... 6 common frames omitted
Caused by: javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
    at sun.security.ssl.SSLSocketImpl.handleEOF(SSLSocketImpl.java:1506) ~[na:1.8.0_321]
    at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1323) ~[na:1.8.0_321]
    at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1228) ~[na:1.8.0_321]
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:412) ~[na:1.8.0_321]
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:384) ~[na:1.8.0_321]
    at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:347) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:194) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:101) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:308) ~[mysql-connector-java-8.0.28.jar:8.0.28]
    ... 11 common frames omitted
    Suppressed: java.net.SocketException: Software caused connection abort: socket write error
        at java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.8.0_321]
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111) ~[na:1.8.0_321]
        at java.net.SocketOutputStream.write(SocketOutputStream.java:155) ~[na:1.8.0_321]
        at sun.security.ssl.SSLSocketOutputRecord.encodeAlert(SSLSocketOutputRecord.java:83) ~[na:1.8.0_321]
        at sun.security.ssl.TransportContext.fatal(TransportContext.java:400) ~[na:1.8.0_321]
        at sun.security.ssl.TransportContext.fatal(TransportContext.java:312) ~[na:1.8.0_321]
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:424) ~[na:1.8.0_321]
        ... 16 common frames omitted
Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:480) ~[na:1.8.0_321]
    at sun.security.ssl.SSLSocketInputRecord.readFully(SSLSocketInputRecord.java:458) ~[na:1.8.0_321]
    at sun.security.ssl.SSLSocketInputRecord.decodeInputRecord(SSLSocketInputRecord.java:242) ~[na:1.8.0_321]
    at sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:180) ~[na:1.8.0_321]
    at sun.security.ssl.SSLTransport.decode(SSLTransport.java:111) ~[na:1.8.0_321]
    at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1315) ~[na:1.8.0_321]
    ... 18 common frames omitted
 

jdk版本过高会引起这种错误;查了很多资料,发现在MySQL5.7之前的版本,安全性较低,存在任何用户都可以连接上的 test 库,所以官方在5.7版本加大了对隐私的保护。并且采用了默认 useSSL = true值防止对数据库的随意修改,到了8.0版本,仍然保留了SSL,并且默认值为 true,所以只要将 “&useSSL= false” 放在url表名后即可。

解决方案在mysql路径后边加上  &useSSL=false    问题即可解决;

如图: 

Caused by: java.io.EOFException: SSL peer shut down incorrectly_第3张图片

你可能感兴趣的:(java,mysql,学习,java,ssl,mysql)