• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

database connection pooling confusion

 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic