-1

I got the below error when i try to connect remote database I use mysql server 5.5,installed all jar files and ran grant previlidge scripts also, Pls help me to resolve the same

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2120)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:723)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at JDBCExample.main(JDBCExample.java:31)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 15 ms ago.
        Caused by: java.net.ConnectException: Connection refused: connect

1 Answers1

0

The error may be because you have not granted permission for remote location.Grant permission like this

GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.205'
    IDENTIFIED BY PASSWORD 'some_characters'  
    WITH GRANT OPTION;
FLUSH PRIVILEGES;
SpringLearner
  • 13,738
  • 20
  • 78
  • 116
  • This may occur for other reason, see this post, http://stackoverflow.com/questions/2121829/mysql-jdbc-communications-link-failure – Masudul Nov 29 '13 at 06:32
  • @Masud I have faced this type of situation once,so posted the answer.well if you feel it does not deserve to be here then i can remove it – SpringLearner Nov 29 '13 at 06:34
  • Permission granting may be the issue. So, your answer has good point. Lets wait until OP reply. – Masudul Nov 29 '13 at 06:45