Multiple resultset - strange problem

Hi,

I have a stored procedure that returns a single resultset correctly.

ResultSet rs = cstmt.executeQuery();

while(rs.next()).......

Now, I have to change this stored proc, to return multiple resultsets. To test if my code works, I did not change the stored proc(it still returns 1 resultset), but changed my code to -

boolean results = cstmt.execute();

System.out.print("do resultsets exist - "+results);

System.out.print("update count- "+cstmt.getUpdateCount());

For some strange reason, the boolean value is false! And the updatecount value is 1.

Can someone pls. explain this? I have the code for retrieving multiple resultsets, but it does not get executed because the initial 'results' value is false.

Thanks in advance.

[796 byte] By [arbitarya] at [2007-10-3 4:33:40]
# 1

I've never done what you're doing. I do it like this:

CallableStatement cs = conn.prepareCall("{call PKG_BLAH.MY_FUNCTION(?,?,?)}");

cs.setLong(1, someKey);

cs.setString(2, someId's);

cs.registerOutParameter(3, ORACLECURSORVALUE);

cs.execute();

ResultSet rs = (ResultSet) cs.getObject(3);

while (rs.next()) {

...

}

SoulTech2012a at 2007-7-14 22:37:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
You need to call getMoreResults() and iterate through that.The first statement must not have been a DQL statement.%
duffymoa at 2007-7-14 22:37:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

Thanks, I finally figured it out. I don't get the resultsets if I fire an execute -

cstmt.execute()

Instead, this is what I do :

rs = cstmt.executeQuery();

System.out.print("first rs");

while(cstmt.getMoreResults())

{

System.out.print("second rs");

ResultSet rs1 = cstmt.getResultSet();

}

This works fine.

arbitarya at 2007-7-14 22:37:17 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...