-3

I am making database connection remotely but i am getting "communication link failure" my code is:

Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://49.58.100.100:3306/abc", "abc1","abc");
System.out.println(con);
ritu
  • 25
  • 6
  • So clearly, whatever machine you're on can't connect to 49.58.100.100 on port 3306. You'll need to look at why that is and take the steps specific to your environment to fix it. We can't do it for you (particularly with so little information to go on). – T.J. Crowder Feb 27 '18 at 08:29
  • Post the full stack trace. Likely your mysql server is unreachable. – BackSlash Feb 27 '18 at 08:29
  • Please elaborate on the issues you are facing. Also, refer [https://stackoverflow.com/questions/8348506/grant-remote-access-of-mysql-database-from-any-ip-address|https://stackoverflow.com/questions/8348506/grant-remote-access-of-mysql-database-from-any-ip-address] – shriyog Feb 27 '18 at 08:30
  • 3
    Separately: [**Please search** before posting](/search?q=mysql+"communication+link+failure"). (More on searching [here](/help/searching).) What about the previous answers to this hasn't worked for you? – T.J. Crowder Feb 27 '18 at 08:30

1 Answers1

1

Try to execute in the cmd :

telnet  49.58.100.100 3306

If you get timeout means the server is not reachable, to solve this you need to open the firewall port in your server.

Korteby Farouk
  • 629
  • 7
  • 14
  • Actually when i am using freemysql its working fine but when i am using cPanel its not working – ritu Feb 27 '18 at 08:43
  • I need to understand what do you mean by freemysql ? if you mean mysql console so the port is open no firewall issue. cPanel is a commercial application allow you to manage your hosting so the best is to contact your hosting company to solve this. – Korteby Farouk Feb 27 '18 at 08:49
  • May be it will helps you [How to Set up a Remote MySQL Database Connection in cPanel](https://www.inmotionhosting.com/support/website/databases/setting-up-a-remote-mysql-connection-in-cpanel) – Korteby Farouk Feb 27 '18 at 08:57