Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

isClosed method of OracleConnection class

Posted on 2004-09-13
7
Medium Priority
?
493 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses

610 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