Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / August 2004

Tip: Looking for answers? Try searching our database.

How to detect when a connection times out ?

Thread view: 
Leny - 25 Aug 2004 13:46 GMT
Hi,

   I'm looking for a standar way to know when a connection has been
timed out.
   Right now, I found the following solutions:

       - Make a query and check out the result. If it's an exception,
reopen the connection.
       - Just check every exception for every query.

    Well, as you can see they are far from ideal solutions. I just
can't check the isClosed() because it only returns true when the
*client* closes the connection.

    Do you know any way to know if the connection is active ? Any
comments would be really welcome.

    Thanks in advance,

         - Leny
Joe Weinstein - 25 Aug 2004 17:38 GMT
> Hi,
>
>     I'm looking for a standard way to know when a connection has been
> timed out.

Hi. There is no standard way. Choose a query or call that you are sure has to go to the
DBMS, and is as fast and uncontentious as possible.

>     Right now, I found the following solutions:
>
>         - Make a query and check out the result. If it's an exception,
> reopen the connection.

That's the only way. Also note that the connection could go bad immediately after your
test query succeeded... The fundamental fact is that a client can never know if it's
next attempt to talk to the server will succeed.

>         - Just check every exception for every query.
>
>      Well, as you can see they are far from ideal solutions. I just
> can't check the isClosed() because it only returns true when the
> *client* closes the connection.

Correct. That is the JDBC spec.

>      Do you know any way to know if the connection is active ? Any
> comments would be really welcome.
>
>      Thanks in advance,
>
>           - Leny


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.