I made a Java program which accesses a database. During the development phase I used a local database (XAMPP with MySQL), but when I tried to access 2 different online databases (a commercial and a free one), I received in both cases the following exception:
SQLException: 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 had not any problems accessing them with PHP.
I'm sure, that my source code is correct. I think it has something to do with ports or the firewall.
netstat -a -n shows me, that the port 3306 is not in use.
These are my parameters:
String user = "user1"; String pass = "pass1"; String dbClass = "com.mysql.jdbc.Driver"; String dbDriver = "jdbc:mysql://db4free.net:3306/DBNAME";
It worked great on other machines, this is the confusing thing. Obviously I need to make sure, that my software works on the most computers.