I need an advice. I have a Java Swing program which uses MySQL database. The MySQL database is in a Linux server and the access is given via a VPN. Below is my JDBC connectivity code.
con = DriverManager.getConnection("jdbc:mysql://"+ip+":3306/databaseName","user","password");
As you can see, user of the software can set the ip
at his side. This is done via the GUI.
So for an example, if the IP
is 127.0.0.1, then the connection will be set to below.
con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/databaseName","user","password");
I have hard codded the user
and password
as well, but I have asked them to create a user account in MySQL with that user name and the password.
AS far as I know, this is the way Java connects to any database, whether it is local or remote or even via VPN. But my client conplaints about Communication Link Failure
error. So is the JDBC connection way is different when you are connecting via a VPN? Or else, you have to change the port
as well? I have hard codded the port to 3306.
As a freelance programmer, I believe client's network admin might have done something wrong, unless the hard codded port is an issue. any advice please?
UPDATE
127.0.0.1 IS JUST FOR AN EXAMPLE...