0

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 userand 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...

PeakGen
  • 21,894
  • 86
  • 261
  • 463
  • Can you can ping the mysql port from the swing app host? If not then it is a network issue. BTW: ip of 127.0.0.1 is for localhost. Are you running mysql and the swing app on the same host? – Khanna111 Dec 04 '14 at 05:46
  • 127.0.0.1 is your local machine. The port could be different. The VPN may not be connected to the same network as the mysql server. Can you connect to it with a JDBC client like SQuirreL? – Elliott Frisch Dec 04 '14 at 05:46
  • @ElliottFrisch: THanks for the reply. You mean the `JDBC` CONNECTION code is correct, but the port might be different? – PeakGen Dec 04 '14 at 05:48
  • @Sniper Of course it could be different. It's configurable. – Elliott Frisch Dec 04 '14 at 05:54

0 Answers0