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