Wait_timeout is too short. Can I have unlimited wait_timeout?


I have implemented a connection pool in my 'application' scope using JSP, servlet. After 8 hours, the connection will be automatically closed. To solve this problem, I find out I can either increase the wait_timeout time or I can try to reconnection the connections after several time. However, I do not how to write a class to listener to this event. I prefer to increase the timeout in MySQL. But how should I set the parameter?
Or if anyone can tell me how I can use the listener in JSP or servlet to reconnection the pool. Thank you
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

After a java.sql.Connection object has been disconnected, there's nothing you can do with it but .close() it, kiss it goodbye, then ask the connection pool for another one.  You shouldn't assume that a network connection will stay up for 8 hours; consider yourself lucky if it goes that long.  

A connection pool should work basically like this:

When a request for a connection comes in:
   If the connection pool is empty, create a new Connection and return that.
   If there is a connection in the pool, take it out of the pool and return it.

When a connection is returned:
   If the pool is already full (to some arbitrary number of connections), then just close() the connection and throw it away.
   If the pool isn't full, then stow the Connection in the pool.

You might want to have the pool test Connection.isClosed() before returning a Connection to a pool user

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.