My code throws an exception every time I execute it though, and it's a pretty odd one as well:
Message: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.
I'm 100% sure localhost is reachable (My music player Amarok uses a database on localhost), the account I'm trying to login with exists (can login using mysql -u) and the password is correct as well.
I also think that it's not the driver, because calling a DriverManager.GetDriver(*the exact same string*) returns a driver.
I've been looking for hours now and can't find the solution to this problem anywhere
Below is part of my code and the terminal output.
private boolean openDB() {
try{Class.forName("com.mysql.jdbc.Driver");}
catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
System.err.println("[SanguineBounty]ClassNotFoundException");
e.printStackTrace();
}
try
{
Driver d = DriverManager.getDriver(mysqlurl+mysqldb+"?user="+mysqluser+"&password="+mysqlpass);
System.out.println("Driver: "+d);
conn = DriverManager.getConnection(mysqlurl+mysqldb+"?user="+mysqluser+"&password="+mysqlpass);
System.out.println ("[SanguineBounty]Connected to database.");
//checkDB();
return true;
}
catch (SQLException e)
{
System.out.println("Connection(conn): " + conn);
System.out.println(mysqlurl + mysqldb +" user: "+ mysqluser+ " pass: " + mysqlpass);
System.err.println("[SanguineBounty]Cannot connect to database server");
System.out.println("Message:"+ e.getMessage());
System.out.println("Error code: "+ e.getErrorCode());
}
return false;
}
Terminal output:
18:11:16 [INFO] Driver: com.mysql.jdbc.Driver@3c1fc1a6 18:11:17 [INFO] Connection(conn): null 18:11:17 [INFO] jdbc:mysql://localhost:3306/sanguineDB user: sanguinebounty pass: <censored> 18:11:17 [SEVERE] [SanguineBounty]Cannot connect to database server 18:11:17 [INFO] Message: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. 18:11:17 [INFO] Error code: 0 18:11:17 [INFO] [SanguineBounty]Cannot connect to database. Disabling SanguineBounty...
If someone knows the answer to this dillema Please share it with me.. It's driving me nuts

New Topic/Question
Reply




MultiQuote





|