[Java] Spring MVC 阿里 ali druid 连接池 Communications link failure 解决方案

#关键字:
Spring MVC spring dao 配置 阿里 druid 连接池 出现

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

#症状:

2017-02-24 14:26:53 [ Druid-ConnectionPool-Create-675798468:1 ] - [ ERROR ] create connection error, url: jdbc:mysql://localhost:3306/fangdb?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true, errorCode 0, state 08S01 com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread
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(NativeConstructorAccessorImpl.java:57)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:526)at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:989)at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:632)at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1016)at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253)at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2284)at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2083)at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:806)at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)

以下是错误信息截图

[Java] Spring MVC 阿里 ali druid 连接池 Communications link failure 解决方案_第1张图片

解决方案:

把jdk从1.7改成1.8

2019-04-16更新
评论有同学说jdk改为1.8同样有问题,怀疑是druid问题。

参考

https://pagespeed.v2ex.com/t/254112

你可能感兴趣的:(Java,Spring,Spring,MVC,连接池)