连接MySQL数据库时出现The dirver has not received any packets from the server

来源:互联网 发布:windows 9 编辑:程序博客网 时间:2024/06/05 17:26

看到网上很多很多的论坛与博客,终于找到我的错误的原因,先上图吧,

使用Connector/J连接MySQL数据库:Communications link failure,The last packet successfully received from the server was *** millisecond ago.The last packet successfully sent to the server was ***  millisecond ago。 这个错误的话,是因为你超过了MySQL的默认闲置时间,要到mini上面改下参数,但是问题的关键不在我,我的错误是:CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driv
er has not received any packets from the server.

解决方法:把Connetion URL=jdbc:mysql://127.0.0.1:3306/mysong

结论:一般而言,默认情况下,root好像只可以通过localhost访问,ip是不可以的,是没有权限,需要修改myslq配置文件。如果数据库和你部署的服务器是用一台机器,那么使用localhost没有问题,要是不在同一台,可能需要改mysql配置,保证ip可以访问。

0 0