Skip to main content

Remote MySQL connection using java application issue

Comments

8 comments

  • 24x7server
    Hi, Did you enable the IP in the firewall from where you are connecting to the database server? If you not, you will need to enable the remote IP first in the firewall to allow connection to port 3306 and then only it will allow you to connect to the database from the remote IP.
    0
  • cPanelMichael
    Hello, It's possible your web hosting provider blocks remote connections to port 3306 (the port MySQL runs on) in the server's firewall rules. I recommend contacting your web hosting provider to see if that's the case. Thank you.
    0
  • skyAkash
    yes i have enabled the remote IP connection in windows firewall for port 3306 but still not getting connect with database .
    0
  • cPanelMichael
    yes i have enabled the remote IP connection in windows firewall for port 3306 but still not getting connect with database .

    Hello, I'm referring to the cPanel server's firewall rules. You'd need to contact your web hosting provider to see if that's the case, as those rules are not manageable without root access to the cPanel server. Thank you.
    0
  • skyAkash
    But i am able to access the same database using python, if that the case then the port must not be accessible form python application also but it creates problem while accessing only from java jdbc application not from python
    0
  • cPanelMichael
    But i am able to access the same database using python, if that the case then the port must not be accessible form python application also but it creates problem while accessing only from java jdbc application not from python

    If your Python application is hosted on a remote server or on your own computer, then it's possible the issue is related to your Java application. Do you notice a specific error message when the connection fails? Thank you.
    0
  • skyAkash
    while accessing from java application i am getting below error every time com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet sent to the server was 42909 ms ago. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2873) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2763) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3299) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:894) at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1382) at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:2708) at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:459) at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:2411) at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1657) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2036) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1888) at PhpMyAdminConnection.main(PhpMyAdminConnection.java:30) Caused by: java.io.EOFException: Can not read response from server. Expected to read 177 bytes, read 3 bytes before connection was unexpectedly lost. at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2332) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2830) ... 13 more
    0
  • cPanelMichael
    Hello @skyAkash, You may want to reach out to the developer of that Java application, or consider posting to a website such as StackOverflow for additional help troubleshooting the code-related reasons why your Java application can't connect to a remote MySQL server. If you believe the issue to relate to the cPanel server, then you'd need to contact your web hosting provider to have them take a closer look. Thank you.
    0

Please sign in to leave a comment.