This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection pools - database shutdown

 
Claudia Vaz
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic