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

Posted on 2009-04-28
Last Modified: 2013-12-14
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.
Question by:andy148
    LVL 20

    Expert Comment

    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?

    Author Comment

    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).
    LVL 20

    Accepted Solution

    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

    Author Comment

    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!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now