We help IT Professionals succeed at work.

How to find out if there a Database ResultSet contains results

help_me
help_me asked
on
221 Views
Last Modified: 2010-03-30
I'm developing a servlet and I need to test whether there are any results in the ResultSet returned from my database query, if there aren't any I want to display an html page which indicates this.
What is the method to determine if there are results, I don't want to use 'next()' as this moves the resultset counter on one.

Please send me the code.

Thanks

Mel
Comment
Watch Question

Commented:
I am afraid you have to call next() and cache the row values if the set is not empty.
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
Statement.executeQuery() never returns null, a ResultSet object (possibly empty) is always returned.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.