File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes connection validation and connection close method in connection pooling when DB is down Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "connection validation and connection close method in connection pooling when DB is down" Watch "connection validation and connection close method in connection pooling when DB is down" New topic
Author

connection validation and connection close method in connection pooling when DB is down

Hareesh Ram Chanchali
Ranch Hand

Joined: Jan 31, 2005
Posts: 110
The scenario is like this.

A connection pool was configured with application server
Minimum number of connections > 0 were configured.
Hence they will be instantiated at server start up.
I used some of the connections and closed them except one.
Meanwhile DB went down.

The requirement is I want to check if this is a valid connection or not with out using a query (possibly with DUAL) and without using configurable options in application servers ( like TestonReserve).

What could be the simplest way without using the query to check the health of the connection as I need to make sure that it is healthier for next set of steps?

Also for the connection in the above scenario, if I cross check the same with null value, will it validate whether it is healthier or not?
also if I close the connection, will it somehow raise an exception as DB is down? or it will simply logically close the connection and release the same to connection pool irrespective whether DB is up or not?

Apprecaite your insights.

Regards
Hareesh


Hareesh Ram Chanchali
SCJP 5.0, IBM Certified Solution Designer
Hareesh Ram Chanchali
Ranch Hand

Joined: Jan 31, 2005
Posts: 110
Hi ,

Sorry ..can this be moved to JDBC please.

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9956
    
163

The requirement is I want to check if this is a valid connection or not with out using a query (possibly with DUAL) and without using configurable options in application servers ( like TestonReserve).


There are application server specific ways to do this. But since you mention you want a generic way, upon your request i'll move this to the JDBC forum.

[My Blog] [JavaRanch Journal]
Kees Jan Koster
JavaMonitor Support
Rancher

Joined: Mar 31, 2009
Posts: 251
    
    5
Dear Hareesh,

Assuming you are working with MySQL and Tomcat, here is some advise to get you started: http://java-monitor.com/forum/showthread.php?t=70

Most servers will have similar options. Pleas read the sample config files that come with your server.

Java-monitor, JVM monitoring made easy <- right here on Java Ranch
 
 
subject: connection validation and connection close method in connection pooling when DB is down
 
Similar Threads
Connection Problem
connection validation when db is down
How to open a connection pool to a database?
connection pooling
Hibernate with Application server connection pool