Remote MySQL connection using java application issue

skyAkash

Registered
Jul 16, 2018
4
0
1
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
 

24x7server

Well-Known Member
Apr 17, 2013
1,912
99
78
India
cPanel Access Level
Root Administrator
Twitter
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
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.
 

skyAkash

Registered
Jul 16, 2018
4
0
1
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
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
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.
 

skyAkash

Registered
Jul 16, 2018
4
0
1
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
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
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.