File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes BEA/Weblogic and the fly likes oracle resultset closing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "oracle resultset closing" Watch "oracle resultset closing" New topic

oracle resultset closing


Joined: May 28, 2002
Posts: 1
i am trying to iterate a resulset returned by a procedure using Java 1.3.0/JDBC /
when i do, it says Connection closed.
what may be the reason ?
Michael Pearson
Ranch Hand

Joined: Mar 11, 2001
Posts: 351
Welcome to JavaRanch.
Please change your name to comply with the naming policy to which you agreed when you registered.
You can change your name here:

You can also find the naming policy here:
Thank You!
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

Check whether u can have closed the connection before calling It would be better if u paste the code here.

Chuck Lowry

Joined: May 29, 2002
Posts: 13
This is a problem I had not too long ago. From what I remember, it seems that if you create a Connection object in the method you are calling and then try to pass back a ResultSet object, the garbage collector will close the connection and therefore the ResultSet object before it gets back to the calling method.
We had two work-arounds for this. One was to never pass ResultSet objects, but rather vectors, arrays, custom objects, whatever containing the data back. The second solution was to create the Connection object in the calling method then pass the Connection to the called method, use the passed Connection to execute the query, pass back the ResultSet, then close the Connection after the ResultSet has been used.
This might give you the gist of passing the Connection object:
public callingMethod()
Connection myconn =
ResultSet rs;
rs = queryMethod(someString, myconn);
public queryMethod(String someString,
Connection myconn)
ResultSet rs;
String sql = "select something from somewhere
where somestring = " + someString;
PreparedStatement ps =
rs = ps.getResultSet();
return rs;
Hope this helps!
I agree. Here's the link:
subject: oracle resultset closing
It's not a secret anymore!