Hi I have this problem only in DB2, I am using plain jdbc to execute a simple query.
Then I fetch the ResultSet and, during the fetch of the result set, I call another method which in turn executes another query (opening and closing anoher ResultSet).
When the control comes back to the caller my original ResultSet is closed, and this is really weird..
PS: the code I post below works correctly with Sql Server and even with DB2 express, but in the client environment (DB2 on Z/OS) with driver version 3.64.82 no.
..........
PreparedStatement pst=conn.prepareStatement(query);
ResultSet rs=pst.executeQuery();
while(rs.next()){
System.out.println("Id:"+rs.getInt("ID"));
System.out.println("ULTERIORE SPECIFICA "+getUlterioreSpecifica(conn,rs.getInt("ID")));
System.out.println("Desc: "+rs.getString("DESC"));
System.out.println("ETA: "+rs.getInt("ETA"));
}
........
//other method
private static String getUlterioreSpecifica(Connection conn, int int1) throws Exception{
String query="select ult_desc from specifica where id=?";
String retVal="";
PreparedStatement pst=conn.prepareStatement(query);
pst.setInt(1, int1);
ResultSet rs=pst.executeQuery();
while(rs.next()){
retVal=rs.getString(1);
}
rs.close();
pst.close();
return retVal;
}