This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Handling stale connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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: 3740
    
  10

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.


[OCA 8 Book] [Blog]
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Handling stale connections
 
It's not a secret anymore!