?
Solved

isClosed method of OracleConnection class

Posted on 2004-09-13
7
Medium Priority
?
491 Views
Last Modified: 2007-12-19
I use the isClosed method in atest java class.
In a while(true) loop I call is closed and print its value.

When I run the class and see the output the value printed is always false. In between if I restart the datbase, still  the value printed is false (whioch actually should be true).

How do I know that the connection is no longer valid before I fire a query.Does this isClosed method help?

Thanks
Regards
JAs
0
Comment
Question by:jas123
[X]
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
7 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 672 total points
ID: 12051817
isClosed:

This method is guaranteed to return true only when it is called after the method Connection.close has been called.
This method generally cannot be called to determine whether a connection to a database is valid or invalid. A typical client can determine that a connection is invalid by catching any exceptions that might be thrown when an operation is attempted.

0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 664 total points
ID: 12051822
What application server are you using? Some of them test conenction occasionalyl and if no longer valid they assign a new one from the connection pool.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12051829
That's a quote from the Java SDK Help about java.sql.Connection.isClosed()
You can read it also at http://www.jguru.com/faq/view.jsp?EID=391332
0
 
LVL 7

Expert Comment

by:grim_toaster
ID: 12051898
This is pretty much the same question as you asked previously, complete with some good answers:

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21121095.html
0
 
LVL 9

Assisted Solution

by:Venci75
Venci75 earned 664 total points
ID: 12052185
execute this code when returning the connection to the pool:

try {
   if (OracleConnection.pingDatabase(0) != 0) {
      // not a valid connection
   }
} ctach (SQLException sqlex) {
      // not a valid connection
}
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

743 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