Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes Why this goes into do...while with null result set? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Why this goes into do...while with null result set?" Watch "Why this goes into do...while with null result set?" New topic
Author

Why this goes into do...while with null result set?

Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
I have a do...while that's giving me a weird problem. I have multiple resultsets returned to a statement, and so I get the first one in the "do" by calling getResultSet(), then I do what I need with it and then have a while statement that checks "getMoreResults() and "getUpdateCount()". However, I always have the last time through where it gets everything from the last resultset, then does the "while" check and continues back to the "do" again, but this time the resultset is NULL!! Why doesn't the while statement keep it from doing that?
do
{
..something..
} while ( !statement.getMoreResults() && ( statement.getUpdateCount() == - 1 ) );
This always goes one resultset too far, giving me a null one inside the "do"!
Anyone know what's wrong?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why this goes into do...while with null result set?
 
Similar Threads
JDBC Connection Pooling
reusing the Statement object
Invalid Object Name
ResulSet issue
Processing of Multiple Resultset