• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connection pools - database shutdown

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Yeah, but is it art? What do you think tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic