I'm trying to connect to a mysql db, but I keep getting error: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
I know the url suppose to be: "jdbc:mysql://server-url:3306"
here is the code:
import java.sql.Connection;
import java.sql.DriverManager;
public class FT_Database_Connection{
private Connection connection;
public FT_Database_Connection(String url, String username, String password){
try{
System.out.println("Loading driver...");
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver loaded!");
String user = username;
String db_pw = password;
System.out.println(url);
System.out.println(username);
System.out.println(password);
Connection test = DriverManager.getConnection(url, user, db_pw);
}catch(Exception e){
System.out.println("Couldn't get database connection.");
e.printStackTrace();
}
}
public Connection get_connection(){
return this.connection;
}
}
Any ideas?
Also, Godaddy ask if I want DSN. What's that mean? Do I need it?
Thanks