Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQLException: cursor is not open

tahirakramMar 11 2008 — edited Mar 12 2008
Hello forum;

I am facing a problem of *"cursor is not open"* exception while iterating resutlset. It seems resultset has been closed before I hit for rs.next(). Here is my scenerio, please suggest me if my thinking is wrong what steps should be taken to resolve it.
void getPoId (Connection con, String paymentSrno){
PreparedStatement pstmt = null;
ResultSet rs = null;
try{
pstmt = con.prepareStatement ("select purchase_order_id from payments_info where payment_srno = ?");
pstmt.setString (1, paymentSrno);

rs = pstmt.executeQuery();

while (rs.next()){
     String poId = rs.getString("1");
     
     someOtherApi (con); /* critical area */
}
}catch(Exception e){
e.printStackTrace();
}
}
above is my scenerio code; I noticed when I pass connection to someOtherApi and then I hit on rs.next it give me the error of cursor not open. If I didnt call this api my methods works fine. So what type of changes this api is making make to cause cursor problem for other openned resultsets of that connection. How can I avoid it or to force this exception to not happen.

Please advice.

Thanks.

Tahir
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 9 2008
Added on Mar 11 2008
2 comments
2,307 views