1

My requirement is that I need to access the database which is hosted on My Web Site on MySql with CPanel. Now I would like to access the content of that database from local java application which is made up of JFrame.

My Question is that how to connect local app woth the connection string of Database which is hosted?

Connection con=DriverManager.getConnection(  
"jdbc:mysql://localhost:3306/","admin","pass@123");  

Please tell me that what should be the connection string.

NIket
  • 914
  • 1
  • 6
  • 19
  • instead of localhost type the ip address of that host, port on which mysql is configured and on the server side you need to allow the remote login from different machine as well. – Bilbo Baggins Oct 16 '15 at 08:52
  • Thanks buddy. Its working now – NIket Oct 16 '15 at 09:02

1 Answers1

1

You just need to do one modification in

Connection con=DriverManager.getConnection(  
"jdbc:mysql://localhost:3306/","admin","pass@123");  

just repace localhost by your website name

Connection con=DriverManager.getConnection(  
"jdbc:mysql://www.myexample.com:3306/","admin","pass@123");  

also go to cpanel of your your website & goto remote access in database sections.

Over there you need to assign your IP address to get access on live hosted database.

If your ISP uses DHCP then you need to make an entry for remote access with % as with DHCP your IP will get change again and again and each time IP changes you need to make an entry for that in your remote access.

With '%' in remote access, it allows any IP address to use that database.

Mr x
  • 828
  • 1
  • 8
  • 25
  • Thanks Mr x for your answer and specification about '%' for remote hosting. I have done all that thing and it was working good but thanks to make post over here so any one else can review it then he not need to search again for Remote access for '%' logic. – NIket Feb 18 '16 at 06:09