File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Checking for empty resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Checking for empty resultset" Watch "Checking for empty resultset" New topic

Checking for empty resultset

Tom Joiner
Ranch Hand

Joined: Sep 19, 2006
Posts: 47
I am running a SQL query which is like this:

And I want to check if the resultset is empty. Looking through the API here:

I don't see the obvious solution. I can of course walk through the resultset twice, the first time counting it, and the second time using it, but this seems like a waste. Is there an API call that returns if it is empty?

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336 returns false when the cursor can't move forward. So:

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1082

Just want to add one thing when you call takes you to first row, make sure you do not call again until you have retrieved value of all columns of first row.


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
I agree. Here's the link:
subject: Checking for empty resultset
It's not a secret anymore!