• 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

jdbc connection pooling and database recycling

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?


PS Don't know if this belongs in the JDBC forum?
Saloon Keeper
Posts: 26263
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.
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic