File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ADO is better??!?

 
R Harvey
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3150
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rs.next() is best way to check for empty resultset..
Why you are not satisfied with that ? Whats the problem you are facing here ?
 
R Harvey
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic