Re: Communications link failure due to underlying exception
Posted by: Tetsuro Ikeda
Date: February 22, 2005 02:54AM

Hi,

Your connection had gotten down when prepared statement was executed.

I assume you are using the property "autoReconnect=true".

(if not, you could get another exception message like "No operations allowed after statement closed")

When you use "autoRecoonect=true" and get the exception, just you need to do is catch the exception and re-try execute query like this.

---
try {
rs = stmt.executeQuery("select connection_id()");
rs.next();
System.out.println("connection_id=" + rs.getString(1));
stmt.executeUpdate("kill " + rs.getString(1));
// this statement cause exception by connection killed
rs = stmt.executeQuery("select connection_id()");
} catch (SQLException ex) {
// ex.printStackTrace();
// ConnectorJ autoReconnect here
rs = stmt.executeQuery("select connection_id()");
rs.next();
System.out.println("connection_id=" + rs.getString(2));
}
---

You can see log like this.

connection_id:20
connection_id:21


Regards,
Tetsuro.

Options: ReplyQuote


Subject
Written By
Posted
Re: Communications link failure due to underlying exception
February 22, 2005 02:54AM
June 09, 2006 04:42AM
August 24, 2006 05:27PM
July 15, 2007 04:27AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.