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?
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)
... 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'.
An IDE is no substitute for an Intelligent Developer.