This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes ADO is better??!? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ADO is better??!?" Watch "ADO is better??!?" New topic
Author

ADO is better??!?

R Harvey
Greenhorn

Joined: Sep 17, 2002
Posts: 20
Hey!
Simple question - is there any way of testing if a resultset is empty OTHER THAN calling rs.next() 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
Regards
Robin
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
rs.next() 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
Greenhorn

Joined: Sep 17, 2002
Posts: 20
Yeah, rs.next() 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 rs.next() 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!
Robin
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
 
jQuery in Action, 2nd edition
 
subject: ADO is better??!?