The while will fail if there are no records.
"Tim Ashman" told something not quite accurate...
> The while will fail if there are no records.
No, it will not "fail" just because the query didn't retrieve any records.
It will just not enter the body of the loop.
Look at the documentation of next() for ResultSet in the API.
[snip]
> > ResultSet rs = course.showStudent();
> >
[quoted text clipped - 4 lines]
> > How can i know whether rs will have records
> > before i print it out?
You don't, or rather "next" will tell you.
If there's no records, rs.next() will return false at the first try, and
will not enter the body of the loop.
> > As i want to print some messages
> > when no record is found.
int numberOfRecords = 0;
while(rs.next())
{
numberOfRecords++;
out.println(rs.getString("name"));
}
if (numberOfRecords == 0)
{
out.println("No records!");
}
// Bjorn A
Tim Ashman - 27 Feb 2004 04:39 GMT
> "Tim Ashman" told something not quite accurate...
>
[quoted text clipped - 4 lines]
>
> Look at the documentation of next() for ResultSet in the API.
Ok I misused the term fail. I meant the condition will fail (false) and run
the while loop statements.
....