• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

jdbc connection pooling and database recycling

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know what happens to the connections in the connection pool if the database server is re-cycled. Does Tomcat figure out that the connections are invalid and rebuilds the pool?

Thanks.

PS Don't know if this belongs in the JDBC forum?
 
Saloon Keeper
Posts: 24287
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is probably about the best forum to ask in, even though what you're actually asking about is the Apache dbcp component. But it's bundled with Tomcat.

For all intents and purposes, Connections in a dbcp object are stored in a Collection object. If you want the whole sordid story, it builds on several Apache commons components, including the extended Apache collections and the apache resource pooler. But you can simply think of it as a java.util.List if you want to.

When you request a Connection, the next Connection on the list is returned. If the list is emply, dbcp will check its configuration and construct additional connections up to the configured limit.

When you close a Connection, the dbcp connection wrapper's close() method returns the Connection to the list for someone else to use.

When the database server is re-cycled OR if the connection times out, dbcp doesn't know or care. In fact, any connections checked out of the pool and in use will exhibit the same behavior as if you'd done a non-pooled connection and the backend dropped out.

The connection timeout issue is actually a more common problem. There are some configuration options on dbcp to allow it to validate a connection before releasing it from the pool. Typically, this is a simple test query such as "SELECT 1 FROM DUAL". If the test fails, the connection is discarded and a new one is used, instead.
reply
    Bookmark Topic Watch Topic
  • New Topic