-1

My code:

String connectionurl="jdbc:mysql://parthramiz.esy.es/u804261533_impac";
Class.forName("com.mysql.jdbc.Driver");
String user="abc";
String passwd="****";
Connection con=DriverManager.getConnection(connectionurl,user,passwd);

Error occur:

CommunicationsException : Communications link failure Last packet sent to the server was 0 ms ago.

Which connection string used?

Serge Ballesta
  • 143,923
  • 11
  • 122
  • 252
  • you should provide your code that where you are getting this error. – Alican Uzun May 12 '16 at 08:06
  • String connectionurl="jdbc:mysql://parthramiz.esy.es/u804261533_impac"; Class.forName("com.mysql.jdbc.Driver"); String user="abc"; String passwd="****"; Connection con=DriverManager.getConnection(connectionurl,user,passwd); – Parth Modi May 12 '16 at 08:15
  • @ParthModi always update your question.no need to write code in comment. – Navoneel Talukdar May 12 '16 at 12:55

1 Answers1

0

This kind of error can occur for few things.

So first thing to check is where your localhost MySQL is running.Check it by typing \s.

Next thing make sure that port number is same.

If still you can't make it work then it's probably permission issue.Give permission grant all on *.* to identified by "password",then run flush privileges, and then replace 127.0.0.1 with localhost and try to reconnect.

Check this SO post.

Community
  • 1
  • 1
Navoneel Talukdar
  • 4,393
  • 5
  • 21
  • 42