[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Maximum database connection Problem

Posted on 2006-07-06
Medium Priority
Last Modified: 2010-03-31


I am using a middle ware integration tool which gets connected to oracle database.

But in the code(Java) there is no where that we are trying to close the result set and the connections . The conenctions are always open.

When the DB is down, still the tool assumes the DB is up and tries to hit the database again and again increasing the number of connections. Once it reaches to the highest level the whole DB is down.

So I just want to know is there any way in java which verifes the connection is up or not  . if the DB is not up we try to connect to the database for three time or may four times, if by that time DB is up it should get connnected  other wise we ask it to sleep for say 3 hours and then try again..

Please help me with this situation.

Question by:ruby_srinivas
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 92

Expert Comment

ID: 17054996
if the db is not then you cannot get a connection to it. it will throw an exception.

Author Comment

ID: 17055051

Yes thats right I get an exception saying that Oracle is not avaliable. But I wan to restrict the number of times it tries to connect to the DB , Say only 4 times and even then if DB is not up then it should sleep for 3 hours and try again..

LVL 92

Accepted Solution

objects earned 252 total points
ID: 17055075
count the number of times u get an exception

Connection getConnection()
   Connection c = null;
   int attempts = 0;
   while (c==null && attempts<3)
           c = ....  // attempt to get a connection
       catch (Exception ex)
LVL 23

Assisted Solution

Ajay-Singh earned 248 total points
ID: 17056110
> When the DB is down, still the tool assumes the DB is up and tries to
> hit the database again and again increasing the number of connections.
> Once it reaches to the highest level the whole DB is down.

Could not understand this... if db is down, you will not get the connection.
If you are getting the connection - the implementation of the connection-pool
is wrong. It should NEVER increment the no of connection if db is down.

You may want to try commons-dbcp framework as connection pooling framework:

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question