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. at sun.reflect.NativeConstructorAccesso
- IP address or hostname in JDBC URL is wrong.
- Hostname in JDBC URL is not recognized by local DNS server.
- Port number is missing or wrong in JDBC URL.
- DB server is down.
- DB server doesn’t accept TCP/IP connections.
- DB server has run out of connections.
- Something in between Java and DB is blocking connections, e.g. a firewall or proxy.
- Verify and test them with ping.
- Refresh DNS or use IP address in JDBC URL instead.
- Verify it based on my.cnf of MySQL DB.
- Start the DB.
- Verify if mysqld is started without the –skip-networking option.
- Restart the DB and fix your code accordingly that it closes connections in finally.
- Disable firewall and/or configure firewall/proxy to allow/forward the port.
通过mysql show processlist 命令检查mysql锁的方法