I'm trying to establish a connection in my Java app with JDBC to access my online database so I can insert and query tables. Here is what I am currently trying: (actual IP/user/pass edited, but they're right since I've done similar from a PHP script)
String url = "jdbc:mysql://984.168.199.70/my_db_name";
String user = "my_username";
String pass = "my_password";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
Connection conn = (Connection) DriverManager.getConnection(url, user, pass);
stmt = (Statement) conn.createStatement();
But this doesn't work, I get the error:
Exception in thread "main" 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.
And the error log is pretty long after that.
So just to point out: I have connected to this server before using a PHP script, and I have used JDBC to connect to and interact with my localhost MySQL databases.
Thanks for any help.