MySql communication link failure solution, mysqllinkfailure

Source: Internet
Author: User

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 ";

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.