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 ADO is better??!? 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 "ADO is better??!?" Watch "ADO is better??!?" New topic

ADO is better??!?

R Harvey

Joined: Sep 17, 2002
Posts: 20
Simple question - is there any way of testing if a resultset is empty OTHER THAN calling or fireing off a "SELECT COUNT()... " query along with your normal query?? In ADO you do something like :
if (rs.bof() & rs.eof()) {....
I was assuming there's some equivalent in Java, but I havent found it.
Would love to be illuminated
Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150 is best way to check for empty resultset..
Why you are not satisfied with that ? Whats the problem you are facing here ?

Spritle Software Blogs
R Harvey

Joined: Sep 17, 2002
Posts: 20
Yeah, is what i'm using. I was just wondering if i'd missed some subtle way of doing an ADO style 'eof & bof' (or using a property of the ResultSet class). I suppose will suffice, but it's not a very neat way to do it IMHO - it means you have to re-set the cursor to the beginning in the case where the resultset is not empty, and it doesn't promote very good readablity. All the other languages i've worked with have this kind of capability, and i was supprised that Java does not!
Never mind, it's not too chronic!
Ken Robinson
Ranch Hand

Joined: Dec 23, 2003
Posts: 101
Try rs.isBeforeFirst().
The Javadoc for java.sql.ResultSet.isBeforeFirst() - RETURNS states:
true if the cursor is before the first row; false if the cursor is at any other position or the result set contains no rows
I agree. Here's the link:
subject: ADO is better??!?
It's not a secret anymore!