cancel
Showing results for 
Search instead for 
Did you mean: 

MaxDB + JDBC ResultSet

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

alexander_schroeder
Participant
0 Kudos

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.

Former Member
0 Kudos

Sorry, Alexander.

I refered to different statements.

I'll have to further investigate rs.getObject(i).toString().

Former Member
0 Kudos

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!

alexander_schroeder
Participant
0 Kudos

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 ...

Answers (0)