报错信息 com.Mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet sent successfu
报错信息
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)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at com.mysql.cj.jdbc.NonReGISteringDriver.connect(NonRegisteringDriver.java:197)
... ...
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
常见解决方法一
检查mysql是否正常连接。IP,端口号,用户名,密码是否正确。至于如何检测,可以使用navicat 测试连接一下。如果连接的上,试试关闭防火墙,让别人连一下你自己的mysql,看看连的上嘛。
url: jdbc:mysql://localhost:3307/platfORM?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL
username: root
passWord: 123
解决方法二
配置文件加上 &useSSL=false,记得改成false。这个是版本的问题,你可以看看别人的讲解。
解决方法三
我的navicat是能正常连接的。但是主机名只能写localhost才能连接,改成IP或者127.0.0.1就连接不上。
mysql中有个user表,将Host字段全部改为%,然后重启mysql。如果你没有安装navicat,可用命令提示符的修改方法,参考此文章:java.sql.SQLException: null, message from server: “Host ‘xxx.xxx.xxx.xxx‘ is not allowed to_凌抆莂的博客-CSDN博客
解决方法四
我的上述的几个方法都使用了,但是还是不行。这个时候你就要看看你安装mysql版本是不是真的是你要的版本了。然后再看看配置文件(安装目录下一个叫“my.ini”的文件)。我最终是换了一下别人的配置文件才正常使用了。观察了一下配置文件,默认字符集不一致,还缺少了一些配置,具体不清楚是哪个导致的。
注意:安装目录、端口号 换成自己的,
来源地址:https://blog.csdn.net/m0_56789428/article/details/127087768
--结束END--
本文标题: 解决com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure问题的操作顺序
本文链接: https://www.lsjlt.com/news/387663.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-26
2024-04-26
2024-04-26
2024-04-26
2024-04-26
2024-04-26
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0