It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes How to check whether DB is alive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How to check whether DB is alive" Watch "How to check whether DB is alive" New topic

How to check whether DB is alive

vignesh bala

Joined: Aug 19, 2006
Posts: 28

Hi Guys,

Please clarify this to me. I have to connect to a DB2 DataBase. I am creating connection object first and using that object to do various transactions. I am creating connection in the constructor of my class.

My problem is,
When my database crashes and immediately recovers to normal state.(I will not know whether DB is crashed). Then I do a query, after this, I am getting the following error: A communication error has been detected. Communication protocol being used: T4Agent.sendRequest(). Communication API being used: OutputStream.flush(). Location where the error was detected: Broken pipe. Communication function detecting the error: *. Protocol specific error codes(s) TCP/IP SOCKETS DB2ConnectionCorrelator: AC16011C.DDBE.060910093948. Can anyone suggest how I can rectify it. Or at least is there any way to know that my DB is restarted? Please Help me.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

You could put a try/catch block and catch the DisconnectException. From there you can write recovery code.

[OCA 8 Book] [Blog]
I agree. Here's the link:
subject: How to check whether DB is alive
It's not a secret anymore!