This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services forum!
  • 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

detecting liveliness of connection  RSS feed

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I detect Liveliness of connection object?
The situation is like this. I have a monitor application which needs to monitor the database and some applications which togeather with the database forms a complete system. As soon as the database goes down, monitor application sends signals to other application to shut them down.
The problem is - how can I detect from my monitor application that database is down. The monitoring application also maintains a pool of connection to database for some purpose. Is there some way to use the existing connections to detect the liveliness of database?

Thanks.
 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Pushker,

you could do a select ... from ... to see if your databse is still up and running (if not you will get an SQL-exception)

Herman
 
Bartender
Posts: 19996
95
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Herman Scheltinga:
hi Pushker,

you could do a select ... from ... to see if your databse is still up and running (if not you will get an SQL-exception)

Herman



... which is basically what the 'keep-alive' logic in the apache dbcp does, if switched on. If the request fails, the Connection is discarded and a new one is obtained. Otherwise the existing Connection is passed out of the pool for the benefit of the user.

I believe a safe, general-purpose test for Oracle is 'SELECT 1 from dual'.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!