I was expecting the wrong behavior from getMoreResults. I am writing
some code that will likely expect more then one result from some sql.
So I wanted to iterate over it.
something like while(iterator.hasNext()) {iterator.next}
So I wrote the following code:
while (!(statement.getMoreResults() == false &&
(updateCount = statement.getUpdateCount()) == -1)) {
ResultSet result = statement.getResultSet();
if (result != null) {
writer.write(result);
}
writer.write(updateCount);
}
The assumption being that I could have 0 - many results and I could
use getMoreResults to cover the 0 case. When the body of the loop
never executed I wrote the unit test to simplify the use case in an
attempt to find my error.
Thanks for the help.
On Mar 22, 10:33 pm, Thomas Mueller <[email protected]>
wrote:
> Hi,
>
> > Right, but it doesn't explain why he gets "Select results:null".
>
> It does. Statement.getMoreResults() is simply the wrong method.
>
> > The culprit seems to be the call to "statement.getMoreResults()"
>
> Exactly. It's wrong to call Statement.execute() and then
> Statement.getMoreResults(). All databases I have tested return
> "false". The correct way is Statement.execute() and then
> Statement.getResultSet().
>
> Regards,
> Thomas
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.