Reputation: 924
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.
Upvotes: 1
Views: 836
Reputation: 866
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.
Upvotes: 1