I had to reinstall MySQL completely because everything was broken and I wanted to set it up clean again. Now I get the following error when I run my application that worked with the previously set up mysql database:
om.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received from the server was 38 milliseconds ago. The last packet sent successfully to the server was 37 milliseconds ago.
I have a java application that connects to the mysql database like this:
static Connection getConnection() {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
String username = "root";
String password = "password";
String url = "jdbc:mysql://127.0.0.1:3306/wnetwork?user=" + username + "&password=" + password;
try{
setConnection(DriverManager.getConnection(url));
} catch (SQLException e) {
throw new IllegalStateException(e);
}
return connection;
}
I also tried it with the username and password outside the jdbc url. The MySQL instance is running, I can connect to it in the terminal and everything else works perfectly fine (as far as I know).
Try:
String url = "jdbc:mysql://127.0.0.1:3306/wnetwork?user=" + username + "&password=" + password + "&useSSL=false";
Just add string: &useSSL=false