jQuery in Action, 2nd edition*
The moose likes JDBC and the fly likes Connection pools - database shutdown Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connection pools - database shutdown" Watch "Connection pools - database shutdown" New topic
Author

Connection pools - database shutdown

Claudia Vaz
Ranch Hand

Joined: Nov 13, 2001
Posts: 44
Hello
I have an EJB which create and activate is a connection to the database through pools in Weblogic6.1.
What happens to the pools during the time the database is shutdown?
after the restart of the database, the pools are active, but where do they point for?

thanks in advance
Claudia
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

In theory (dependin on how the driver was written), it may be possible to test Connection.isClosed() before using the Connection - but this neither guaranteed nor recommended.
The description for isClosed also says:
This method generally cannot be called to determine whether a connection to a database is valid or invalid. A typical client can determine that a connection is invalid by catching any exceptions that might be thrown when an operation is attempted.

Basically it is the Connection Pool's job to ensure the validity of any Connection before it hands it out. One mechanism to accomplish this (used in earlier WebLogic servers, no idea if it still does) is to give the pool a valid, light SQL statement it can execute. This statement can be run periodically to test whether the Connection returns values correctly or if it throws exceptions.
Dave
Juanjo Bazan
Ranch Hand

Joined: Feb 04, 2002
Posts: 231
Originally posted by David O'Meara:
One mechanism to accomplish this is to give the pool a valid, light SQL statement it can execute. This statement can be run periodically to test whether the Connection returns values correctly or if it throws exceptions.

Dave is right. And a good and light test is use the conection.getMetaData method() and check if it throws an exception.
something like this:
try{
c.getMetaData();
}catch(Exception e){
//throws a SQLException if a database access error occurs.
}
//Otherwise the conection is OK
-HTH
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection pools - database shutdown
 
Similar Threads
Oracle Connection / No.Of User
server.xml:has to do anything with database access pools
JDBC/JNDI Database Restore
J2ee app gets stuck at a stored procedure call
changing database