my dog learned polymorphism*
The moose likes JDBC 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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to check whether DB is alive" Watch "How to check whether DB is alive" New topic
Author

How to check whether DB is alive

vignesh bala
Greenhorn

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:

com.ibm.db2.jcc.a.DisconnectException: 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: 3700
    
    5

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


My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to check whether DB is alive
 
Similar Threads
java.sql.SQLException: I/O Error: DB server closed connection
Communication error
DB2 Setup in Weblogic5.1/6.1
DB2 StaleConnectionException
TCP/IP SOCKETS T4Agent.sendRequest() OutputStream.flush() Broken pipe * 0