We think we're having problems with our db vendor's ODBC driver (smaller player, not Oracle or Microsoft or MySQL), and while we're waiting for them to scout out problems on their end, we're trying to see if there's any code we can tweak in our
J2EE web app. I'm trying to understand some of the connection pooling code written by a developer no longer with us--it looks very similar to the stuff posted widely on the web, but I have some questions...
Every 30 seconds our ConnectionReaper
thread tries to reap connections that are stale by going through all connections in the pool and calling removeConnection:
timeout is a long value declared as final and is set to 600000, which if treated as milliseconds comes out to 600 seconds, or 10 minutes (so I'm wondering why the comment talks about being a minute old). I checked source histories back to last summer, and it was still 600000 back then in the early days. As you can see, if a connection meets the criteria, removeConnection gets called:
I'm wondering if we should be removing an element from the connection pool if it's possible that the connection won't get closed! When we catch an exception, should we be adding it back to the pool? We are seeing instances where our pool size decreases below the number of connections reported open by the database.
Here is PooledConnection's close method:
PooledConnection implements Connection, and here, that conn object is actually declared as a Connection object. Is it not possible to see the source for java.sql.Connection (is that package closed to us) so that I can see exactly what happens when Connection's close method is called? And should we always be so nonchalant as to simply catch the SQLException when a connection isn't closed?
We're concerned that sometimes connections don't get closed by the driver when they're closed in our code, and we're using a multivalue db, so we don't have a lot of options for drivers to use with
Java apps!
Please, any advice would be greatly appreciated!
