This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes Testing for empty ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Testing for empty ResultSet" Watch "Testing for empty ResultSet" New topic
Author

Testing for empty ResultSet

Jason Stockmann
Greenhorn

Joined: Jun 25, 2002
Posts: 6
I need to test to see if a returned resultset is empty in order to trigger a message being displayed...how do i test for an empty resultset?
(Need this ASAP if anyone can help!)
Thanks!
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403

[ June 25, 2002: Message edited by: James Swan ]
Jason Stockmann
Greenhorn

Joined: Jun 25, 2002
Posts: 6
OK, i tried this:

and then using

but when i serve it up to my jsp, it displays it with one less row (the first i believe)...any suggestions anyone?
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
Ok well rs.next() etc. actually moves the db cursor from its current position, so that why you are getting results off by 1.
How about trying something like this instead then:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Testing for empty ResultSet
 
Similar Threads
lack of exception
cant get it to update
JSP what's wrong with following code?
ResultSet return value for an empty query
Counting number of records in result set