• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Connection pools - database shutdown

 
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
 
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
 
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
 
You can't have everything. Where would you put it?
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!