File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Connection Issue 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 "Connection Issue" Watch "Connection Issue" New topic

Connection Issue

arum mugam

Joined: Nov 02, 2004
Posts: 1
We have an application which uses Oracle 8.1.7. We have connection pool which creates 5 connection on startup of the application.

Scenario 1:
Database server running. Tomcat server running. - Application works fine

Scenario 2:
Database server shutdown. Tomcat server running- Application Fails

Scenario 3:
Database server started. Tomcat server running - Application Fails

Scenario 4:
Database server running. Tomcat server restarted- Application works fine.

In the scenario 3, I want the application to run (ie., with out restarting the Tomcat server being restarted).

Can some one pls help?
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

which database pooling are you using? You need one that detects stale connections and refreshes them. I'm not aware of one offhand, but I know they are out there. (The weblogic pool has been doing it for years)

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33119

If you can't find a connection pool that deals with stale connections, you can handle this yourself.

The first time an application accesses the database, catch any SQLExceptions thrown and try again. Make sure to only try one more time in case the db really is down. This is easy to implement and very portable. Most drivers will realize the connection is stale after trying to use it and get you a new one the second time.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Connection Issue
It's not a secret anymore!