on 01-05-2006 9:43 AM
Hi everybody,
is there any known issue with using 'nested' result sets?
I'm thinking of something like that:
ResultSet rs1 = null;
ResultSet rs2 = null;
rs2 = stmt.executeQuery("...");
rs1 = stmt.executeQuery("...");
rs2.close();
rs1.close();
I encountered a problem when using a structure like this:
rs1 was somehow closed without having been closed by program?! So a null pointer occured.
Hello Rainer,
per statement object you can only have one result set at a time. So use another statement instance if you need two result sets, e.g.:
ResultSet rs1 = null;
ResultSet rs2 = null;
rs2 = stmt2.executeQuery("...");
rs1 = stmt1.executeQuery("...");
rs2.close();
rs1.close();
But you should get a SQLException then, not some 'NullPointerException'. If you got a NullPointerException from your example, please let me know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexander,
I debugged with IntelliJ IDEA:
System.out.println(rsCSV);
=> com.sap.dbtech.jdbc.ResultSetSapDB@3c33d3
System.out.println(rsCSV.getObject(i).toString();
=> column value
First loop ok, 2nd loop with the SQL error:
com.sap.dbtech.jdbc.exceptions.ObjectIsClosedException: SAP DBTech JDBC: Object is closed.
at com.sap.dbtech.jdbc.ResultSetSapDB.assertNotClosed(ResultSetSapDB.java:2706)
at com.sap.dbtech.jdbc.ResultSetSapDB.findColumnInfo(ResultSetSapDB.java:2748)
at com.sap.dbtech.jdbc.ResultSetSapDB.getObject(ResultSetSapDB.java:1107)
at org.apache.jsp.list$jsp._jspService(list$jsp.java:4276)
As I said, no idea why the object (rsCSV?) has been closed?
Thanks for your help!
I would now suggest making a JDBC Trace (see http://sapdb.2scale.net/maxdb-wiki/JdbcTrace).
Without seeing the sequence of calls one cannot say anything about the reason but I would bet that you access a result set on a statement that already had executed another query ...)
However, in the JDBC trace you will see whats going
on ...
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.