The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Unable to Connect to MySQL Database from my Java app

Discussion in 'Database Discussions' started by aparsharma, Sep 19, 2011.

  1. aparsharma

    aparsharma Member

    Joined:
    Sep 19, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    I am facing an issue with connecting my J2EE application with the MySQL on CPanel.
    I tried to connect the MySQL database with SQLYog also, but i am facing the issue Error: 2003 (Can't Connect to MySQL server on ....my IP or domain (10060))

    I did the things that should be done like

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

    I am using the following parameters in my J2EE application while connecting...

    - Host name is Shared IP as given in the Shared IP Address on the CPanel Home page( I am not sure if this is
    correct, else I dont know how to get the Host name from CPanel)
    - Database name is Cpaneusername_mydatabasename
    -
    Database password is my custom password
    - Database Url is jdbc\:mysql\://<MyDomain or Host name>\:3306/<MyDatabaseName on Cpanel>


    I don't know how to proceed further on this.

    Thanks,
    Apar
     
  2. milind

    milind Well-Known Member

    Joined:
    Jan 15, 2006
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Nasik (Maharashtra), India
    cPanel Access Level:
    Root Administrator
    is your J2EE application and MySQL database is on different server? if no then try to use localhost as Hostname.
     
  3. aparsharma

    aparsharma Member

    Joined:
    Sep 19, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hi Milind,

    Thanks for the reply.
    My J2EE application is on my local machine.
    And I am connecting from my local to the MySQL database on the CPanel.

    Thanks,
    Apar
     
  4. milind

    milind Well-Known Member

    Joined:
    Jan 15, 2006
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Nasik (Maharashtra), India
    cPanel Access Level:
    Root Administrator
    Can you please try telnet <mysql host IP> 3306 from command prompt of your local machine?
     
  5. aparsharma

    aparsharma Member

    Joined:
    Sep 19, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hi Milind,

    I did telnet for the IP and the domain both

    Its returning the following error (in case of IP below)

    Connecting To xxx.xxx.0.60 Could not open connection to the host, on port 3306: Connect failed

    Thanks,
    Apar
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Do you have a firewall running? It might be blocking port 3306 incoming on the server.
     
  7. aparsharma

    aparsharma Member

    Joined:
    Sep 19, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    I have to connect to the server which is hosting MySQL. It runs CPanel on it.

    I do not have access to their servers. I dont know if they are running firewall.

    Though I can do Http tunneling and connect from SQLYog but not through a j2ee app.

    Also, It may be possible I am giving a wrong Host IP.

    Please tell me how to find the correct host IP running CPanel.

    I did ping <mydomain>.com, and it gave me an IP which is the same as Shared IP that can be seen from the left hand side information on the CPanel home page. Is that correct?

    When i go to my hosted mySQL database from Cpanel, the Url is something like <mydomain>:2082/.....

    Does it mean i have to go through port 2082 first and then go to 3306.
     
    #7 aparsharma, Sep 19, 2011
    Last edited: Sep 19, 2011
  8. milind

    milind Well-Known Member

    Joined:
    Jan 15, 2006
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Nasik (Maharashtra), India
    cPanel Access Level:
    Root Administrator
    Please contact your hosting company with the error you are getting.

    I don't think so because in most of the cases domain and database is hosted on same server but might be your hosting company allowing access on port 3306 through a particular IP only (again this is related to firewall).

    No its not like that, you will able to connect directly to port 3306 without any problems once the problem is fixed.
     
  9. aparsharma

    aparsharma Member

    Joined:
    Sep 19, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Thanks for the reply.

    I have the domain hosted on a different server and its pointing to the CPanel server which has MySQL.

    Since I am using the Host IP of the Cpanel server to connect, should it make any difference.

    So, I have to check with the administrator of the Cpanel server, whether they are running firewall or not.
     
  10. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Yes, you need to contact the provider of the cPanel machine to ask whether they have port 3306 opened for incoming connections. They also need to have a connector (jdbc or whatever) for your application to work with MySQL. If they don't have that connector on the machine, you won't be able to get the application to connect whether port 3306 is opened or not. These are all questions that should be directed to the provider of the server.
     
  11. aparsharma

    aparsharma Member

    Joined:
    Sep 19, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Thanks for the reply.
    I will contact the server admin.
     
  12. milind

    milind Well-Known Member

    Joined:
    Jan 15, 2006
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Nasik (Maharashtra), India
    cPanel Access Level:
    Root Administrator
    Please let us know if your problem is fixed or not (if possible let us know the problem) as it will help everyone here as well :)
     
  13. aparsharma

    aparsharma Member

    Joined:
    Sep 19, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hi Milind,

    Sure! For everyone who would have the same problem.

    I contacted the server admin who is hosting CPanel. I mailed him asking why I am not able to connect my Java application to
    the mySQL hosted on CPanel.

    He replied saying that, Remote mysql access is disabled because of security reasons.
    I am following up with the admin of the server there to provide me some kind of access to MySQL.

    Anyway, this did not come out to be a CPanel issue. And, I am thankful to Milind and CpanelTristan for replying diligently.

    Thanks again!!!
    I may bother you guys again in the future!:)
     
  14. milind

    milind Well-Known Member

    Joined:
    Jan 15, 2006
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Nasik (Maharashtra), India
    cPanel Access Level:
    Root Administrator
    Anytime mate :)
     
Loading...

Share This Page