This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Recognizing stale connections in connection pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Recognizing stale connections in connection pool" Watch "Recognizing stale connections in connection pool" New topic

Recognizing stale connections in connection pool

Steve Tharp

Joined: Mar 19, 2001
Posts: 10
Does anyone know the best way to identify stale connections in a connection pool? Our application resides on a webfarm and connects to a DB2 database on an OS/390 mainframe using DB2Connect. The problem is the database is set to break connections after 10 minutes but the database does not notify DB2Connect when a connection has timed out and therefore my connection pool class still thinks the connection is available thus causing errors when a servlet grabs a stale connection.
What is the best way for the connectionpool class to determine if the connection is still valid? (I've tried connection.isClosed() and this does not work) Would getMetaData be an option? Or what about a simple query to test it? Any help is greatly appreciated!
I agree. Here's the link:
subject: Recognizing stale connections in connection pool