This is how I try to connect:
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception e) {
throw new DbConnectionException();
}
try {
connection = DriverManager.getConnection(url,username,password);
} catch (SQLException e) {
e.printStackTrace();
throw new DbConnectionException();
}
I am 100% sure that the URL, username and password are correct. I have already successfully connected to an external tool (MySQL query browser). This is the error I get:
com.mysql.jdbc.CommunicationsException: Communication communication error due to underlying exception:
** START EXCEPTION FAULT **
java.net.SocketException MESSAGE: java.net.ConnectException: connection refused
...
source
share