File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Handling stale connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Handling stale connections" Watch "Handling stale connections" New topic
Author

Handling stale connections

Venkat Sadasivam
Ranch Hand

Joined: May 10, 2008
Posts: 139
Hi, How to handle stale connections? The application hangs when database server restarts.


“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

Catch them and reconnect? If a connection dies, the application will throw an exception after some timeout value. You can catch these exceptions and decide a recovery path. You could also set up a polling thread to monitor the database status although this might be overkill.


My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handling stale connections