GeeCON Prague 2014*
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
Author

oracle resultset closing

ajap
Greenhorn

Joined: May 28, 2002
Posts: 1
i am trying to iterate a resulset returned by a procedure using Java 1.3.0/JDBC /classes12.zip
when i do Result.next, 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:
here

You can also find the naming policy here:
http://www.javaranch.com/name.jsp
Thank You!
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

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


Groovy
Chuck Lowry
Greenhorn

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 =
ConnectionPool.getConnection();
ResultSet rs;
rs = queryMethod(someString, myconn);
doSomthingWithRS(rs);
rs.close();
myconn.close();
}
public queryMethod(String someString,
Connection myconn)
{
ResultSet rs;
String sql = "select something from somewhere
where somestring = " + someString;
PreparedStatement ps =
myconn.prepareStatement(select);
ps.execute();
rs = ps.getResultSet();
return rs;
}
Hope this helps!
 
GeeCON Prague 2014
 
subject: oracle resultset closing