This error message may include the following text also:
"The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."
When we try to connect to a MySQL server "Communications link failure" error may occur for any of the following errors:
i) MySQL server is not running. Check for this and run the sever if it is stopped.
ii) Host name is wrong: If the server is running in the same computer, the correct host name is localhost otherwise it is a valid IP address or computer name.
iii) Wrong port no given : By default MySQL server runs in port 3306. If it is different, check that correct port no is given.
public static Connection getConnection()
Connection connection = null;
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/database","username","password");
System.err.println("MySQL driver not found");
If the above solutions do not work for you. Please comment below giving your code. I'll try to respond.