I have a private vps, the vps is ubuntu 12.04 using zpanel for phpmyadmin, set up to running a MySQL database already but when I try to connect to the database with Java I am unable to and receive the message:
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."
This is my connection code:
package net;
import java.sql.*;
import javax.swing.JOptionPane;
public class LoginDatabaseConnection {
Connection conn = null;
public static Connection ConnectDB() {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://vps35560.vps.ovh.ca/zadmin_login", "*masked*","*masked*");
System.out.print("Connection Establish");
return conn;
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
System.out.println(e);
return null;
}
}
}