com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Kommunikationsverbindungsfehler [Duplikat]

Diese Frage hat hier bereits eine Antwort:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Kommunikationsverbindungsfehler 32 Antworten

Mein Programm, das eine Verbindung zu einer MySQL-Datenbank herstellt, hat einwandfrei funktioniert. Ohne Änderung des zum Einrichten der Verbindung verwendeten Codes erhalte ich dann die folgende Ausnahme:

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.

Was ist passiert?

Der Code, mit dem die Verbindung hergestellt wurde:

private static Connection getDBConnection() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
    String username = "user";
    String password = "pass";
    String url = "jdbc:mysql://www.domain.com:3306/dbName?connectTimeout=3000";

    Class.forName("com.mysql.jdbc.Driver");
    Connection conn = DriverManager.getConnection(url, username, password);
    return conn;
}

Antworten auf die Frage(15)

Ihre Antwort auf die Frage