Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Test for an empty ResultSet
12-21-2010, 08:22 AM (This post was last modified: 12-21-2010 08:23 AM by tutorials4u.)
Post: #1
Test for an empty ResultSet
boolean found;
ResultSet rs;
...
// execute the query and then
found = rs.next();
if (found)
System.out.println("Record found");
else
System.out.println("RECORD NOT FOUND");

A nicer way to do the same would be

ResultSet rs;
...
if (rs.next()) {
do {
System.out.println("Record found");
} while (rs.next());
}
else {
System.out.println("Record not found");
}
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:



Send your comments, Suggestions or Queries regarding this site at info@tutorials4u.net

Copyright © 2010 Tutorials4u.net All Rights Reserved