| Author |
Detect a lost of connection.
|
Nicolas Lavacry
Greenhorn
Joined: Jul 05, 2004
Posts: 1
|
|
How could I detect correctly a lost of connection without exception catching ? Is there any listener or method to implement ? Best Regards.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
No. Its exceptions or nothing.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Andy Nimmo
Greenhorn
Joined: Mar 30, 2003
Posts: 14
|
|
Paul, That's not strictly true. Although exceptions are the best way of dealing with an occurance of a showstopping situation there are other ways to do things. In this example Nicolas wants to just check if the connection is still alive and well which can be done quickly and easily without waiting for an exception to be thrown. Have a look at the following code which I am using in one of my database access classes: This simple example checks to see if the connection is alive before it attempts to send a Query. If the connection isn't alive then it attempts a single re-establishment of the connection before failing. Hope this helps. Andy.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
Doh! Well caught Andy. That will teach me to answer questions without double checking the docs.
|
 |
ramandeep mann
Greenhorn
Joined: Aug 17, 2006
Posts: 13
|
|
But What if query is already been fired and server is waiting for reply.On the other side Firewall or something else drop the connection before receiving the reply.I am in such a situation ======================== We have such a query which takes more then 2 hours and database is on other machine.But my application server is behind the firewall so this firewall is dropping the ideal connection (waiting for results )after every hour . ========================
|
 |
 |
|
|
subject: Detect a lost of connection.
|
|
|