MySql communication link failure solution, mysqllinkfailure
When using JDBC to connect to mysql, you may encounter the following errors:
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 supported Ed any packets from the server
Solution:
Set
String url = "jdbc: mysql: // 192.168.xxx.xxx: 3306/db ";The IP address is added to the hosts file and connected using the name set in hosts. Example:
String url = "jdbc: mysql: // 127.0.0.1: 3306/db ";Change
String url = "jdbc: mysql: // localhost: 3306/db ";This error may encountered when using JDBC to connect Mysql:
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 supported Ed any packets from the server
Sulotions:
You need add target IP to your hosts file and name it.
MakeString url = "jdbc: mysql: // 192.168.xxx.xxx: 3306/db"; beString url = "jdbc: mysql: // hostname: 3306/db ";
Example:
String url = "jdbc: mysql: // 127.0.0.1: 3306/db ";Change
String url = "jdbc: mysql: // localhost: 3306/db ";