My server-side Java program is crashing due to MySQL timeout

After about 6 hours, my server-side Java program refuses to allow anyone to connect. My error is below, maybe someone can make sense out of it.
error.JPG
andy148Asked:
Who is Participating?
 
VenabiliCommented:
Well - this simply means that a new connection or an action could not be perform until the timeout -- in most cases simply because it is on hold waiting to do anyth9ng because of other connections blocking it. So no - a longer period might even be worse because this will keep your connections waiting... Any chance of leaving some connections for too long so when you try to use them again they are already dead?

I would try to go through the code and track down every opening, usage and closing of a connection. Do you also close Statements, PreparedStatements and ResultSets? Also when it fails again, try to see how many connections are open at the moment (netstat for example)  to the DB server
0
 
VenabiliCommented:
How do you get your connections? Some type of pool?
Looks to me that either you keep reuisng the same object and never check if it is correct or you have issues in your pool... or you simply leave a lot of connections to hang out and you cannot do any more...

Does a restart help?
0
 
andy148Author Commented:
Yes, a restart does help. I think I'm properly closing connections when they are done, I also automatically close active connections if there is no activity between them in about 10 minutes. It says something about .... is longer than the server configured value of 'wait_timeout'. I'm not sure where this is defined though, it's not in my application. Anyway, would setting 'wait_timeout' to a Ridiculously large number fix the problem (or at least allow the program to last longer without a reboot)? Oh yes, I know it isn't too many connections, I'm still in the testing phase, and I have only 2 computers (so only 2 connections max to the server).
0
 
andy148Author Commented:
Sorry for the long delay, I was doing some testing and forgot about this question. I found the problem, I wasn't properly closing the connections. I found that after a bit of testing that there were multiple connections to the server from the same machines. I revised my code and it appears to be working, left server online for more than 24 hours and no problems. Thanks for your help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.