Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Remote MySQL connection using java application issue

Discussion in 'Database Discussion' started by skyAkash, Jul 20, 2018.

Tags:
  1. skyAkash

    skyAkash Registered

    Joined:
    Jul 16, 2018
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Website Owner
    Hi Team

    I tried to make remote connection to Cpanel phpmyadmin from my java application .


    I did the things that should be done like

    - Add the User to the mySQL database on CPanel
    - Add the Host to the Remote MySQL Access Hosts
    - I verified the username and password too


    Can somebody help me on this , is there some issue at Cpanel side due to which i am not able to make connection to Cpanel database .I am stuck with my work .

    Thanks
    Akash Yadav
     
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,880
    Likes Received:
    89
    Trophy Points:
    78
    Location:
    India
    cPanel Access Level:
    Root Administrator
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. skyAkash

    skyAkash Registered

    Joined:
    Jul 16, 2018
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Website Owner
    yes i have enabled the remote IP connection in windows firewall for port 3306 but still not getting connect with database .
     
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. skyAkash

    skyAkash Registered

    Joined:
    Jul 16, 2018
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Website Owner
    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
     
  7. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. skyAkash

    skyAkash Registered

    Joined:
    Jul 16, 2018
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Website Owner
    while accessing from java application i am getting below error every time
    Code:
    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
    
     
    #8 skyAkash, Jul 21, 2018
    Last edited by a moderator: Jul 21, 2018
  9. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice