-2

I have a Java (Swing) desktop connected to a godaddy MySQL database (online database). Till the time database was offline, this was not at all the problem, but now I get this exception when I try to access some menu which involves a database access. Also, I create a static connection object when my application start, and never close it when the application is running.

This is the description of Exception, please help if you can.
Thanks :)

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link fai lure

Last packet sent to the server was 47 ms ago.

SOME MORE STACK TRACE AND THEN THE CHAINED CAUSE

Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.

Gagan93
  • 1,826
  • 2
  • 25
  • 38
  • Wow.. You got an exception. Cool. Um. Now what do I do with that information?? IOW: What is your question? What do you need help with? – Vogel612 Apr 02 '15 at 11:05
  • @Gagan93 you need to add the snippet that cause the problem and edit some information which turns to be broad at this moment. thanks – neferpitou Apr 02 '15 at 11:35

1 Answers1

2

I am assuming that you are on a shared hosting. Connecting to such a hosting publicly is not advisable. Dealing with the problem this seems a problem with Remote SQL. There are a few things you can do 1. Go to your cPanel or equivalent and navigate to Remote SQL add the address 0.0.0.0 which will allow connections from any public ip that may want to connect with it. If your are using a vpn like AWS you have to manually edit the my.cnf or my.ini depending on weather you are hosted on linux or windows, add

bind-address = 0.0.0.0

under the

[mysqld]

tag

  1. Next you need to create a user which can be accessed from any ip as root user only has permission to be accessed locally

    GRANT ALL ON yourdatabasename.* TO user@'%' IDENTIFIED BY 'yourRootPassword';

Ashmeet Singh
  • 344
  • 1
  • 5
  • 17
  • hey ashmeet ! thanks for the response ...actually its a shared hosting + windows server (plesk for both ASP and PHP). I wanted by app to work asap, so created PHP web services which are doing the same. After googling alot, I figured out that it is a stale connection problem. The reason behind is wait_timeout attribute of MySQL database. – Gagan93 Apr 11 '15 at 16:21