troubleshooting Question

Connection Pool vs localized Connection use...

Avatar of bganoush
bganoush asked on
10 Comments1 Solution436 ViewsLast Modified:

Hello World!

Recently I was asked to change my code from a single-use connection based model to a connection pool model for all database use.

The only reason for this is that my code would litter the netstat full of TIME_WAIT connections that seem to multiply like rabbits in spring...

So my solution was to implement a connection pool. That exercise took the better part of a morning and now the TIME_WAIT issue is gone although I may be faced with another issue. I was wondering what would happen once my connections started to get aborted from the default timeouts for connections... Well I think I fixed that by looking at the "isClosed()" method of the Connection class and then resetting the connection member of my connection pool set.

I'm sure there are other caveats that I'll find along the way but for now I just hope it will work...

The reason I posted here is to ask your opinion...  In the "Java World" is there a standard or what is your opinion as to what method is best to use?  I know so many people who say that you should create and close a connection right away but then in the case of my application, that leaves you with TIME_WAIT connections.  And then there is pooling... and  everything that goes with that.

By the way, the main reason that I was accumulating so many TIME_WAITs orginally was because I have a queue in one of my tables that I need to poll  every few milliseconds for incoming data so I open a connection, check the queue with a select statement and then close the connection... repeat...

-- Bubba
Mick Barry
Java Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2010

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 10 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 10 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004