ubuntu16.04下eclipse使用 jdbc连接本地mysql出现:Communications link failure错误
来源:互联网 发布:会计电算化软件 编辑:程序博客网 时间:2024/06/06 20:04
具体错误: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.
被这个问题困扰类不少时间,网上帖子看了一遍有一遍,归纳了3种解决方式:
1.首先考虑 配置文件/etc/mysql/my.cnf
网上说是出现这个问题是因为超时,数据库连接(java.sql.Connection)连接关闭,因此可以设置连接最长时间,wait_timeout的默认最长时间是28800秒,也就是8小时时间
以root打开该文件:sudo gedit /etc/mysql/my.cnf
再末尾添加:
[mysqld]
wait_timeout=31536000
interactive_timeout=31536000
保存退出
2.考虑是否是驱动版本问题,比如:将mysql-connector-java-5.1.14-bin.jar换成mysql-connector-java-5.1.19-bin.jar试试;
3.将 String url = "jdbc:mysql://localhost:3306/test";//?autoReconnect=true&failOverReadOnly=false
中的localhost换成127.0.0.1
0 0
- ubuntu16.04下eclipse使用 jdbc连接本地mysql出现:Communications link failure错误
- sqoop连接mysql出现 Communications link failure
- 远程连接mysql的“Communications link failure”错误解决方案
- com.mysql.jdbc.CommunicationsException: Communications link failure
- MySQL连接超时Communications link failure
- MySQL连接超时Communications link failure
- mysql: Communications link failure
- mysql Communications link failure
- mysql-错误:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- Mysql报com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure错误
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure连接报错解决方法之一
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- 解决com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- 解决com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- 关于代码整洁的一些坑
- Retrofit的个人总结
- Integer.valueOf 返回对象的差别
- 新博客开启
- android 手把手教你实现集成支付宝支付功能
- ubuntu16.04下eclipse使用 jdbc连接本地mysql出现:Communications link failure错误
- centos 6.X 升级Python2.6到python2.7
- Semaphore使用之公平锁
- leetcode3
- 云客Drupal8源码分析之权限系统(下)
- 【转】Gerrit使用介绍
- Android Data Bindings(数据绑定库)
- 【搜索】洛谷 P1519 穿越栅栏 Overfencing
- libevent学习笔记