I was wondering how I can loop through all records in a database?

I'm using a do while loop to loop through all the records in a database is there a way I can simulate to EOF. I tried something to simulate it but I don't think it'll work. I assume there's a better way.
Here's my code:
boolean noRecords=false;
do
noRecords=false;
if (queryResults.next())
serverOutput.print(queryResults.getInt("itemID");
serverOutput.println(queryResults.getString("itemName");
else
noRecords=true;
}while(noRecords==false);

i think i know what you mean...
try this
while (queryResults.next()) {
serverOutput.print(queryResults.getInt("itemID");
serverOutput.println(queryResults.getString("itemName");
when .next() returns false, it will exit the while loop. you don't need the other code you have there, the above should do it all.
is that what you're after?

Similar Messages

Maybe you are looking for