I have am using weblogic for getting connection.
My doubt is I am printing
NOTE: here conn means weblogic connection
I observed the connection closed is TRUE. But still I am able to print the connection as mentioned in the output.
But as per my knowledge connection should be null after connection is closed. IS IT CORRECT?
rajareddya reddy wrote:But as per my knowledge connection should be null after connection is closed. IS IT CORRECT?
If you mean that you think that closing a Connection object somehow assigns null to a variable which referred to that object, then no, that isn't correct. What is this knowledge of yours which told you such a thing?
Jayesh A Lalwani wrote:When a connection is closed, the object of the wrapping Connection class doesn't go away, just the underlying native connection is closed. Any references that you have to the Connection object will still be referencing a COnnection object.
This principle is, however, true for all connections - physical as well as those from connection pools. Calling close() on a connection, or any other JDBC resource (such as ResultSet or PreparedStatement) closes the resource. Trying to use other methods of Connection, ResultSet or similar instance after close() has been called on it therefore usually causes an SQLException.
JDBC interfaces, including Connection, contain the isClosed() method, which could be used to see whether the resource was closed or not.