Re: Count the nuimber of results in a Result Set
- From: "Robert Klemme" <bob.news@xxxxxxx>
- Date: Tue, 24 May 2005 11:19:34 +0200
> In article <1116880543.232237.83620@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
> nicholas.parnell@xxxxxxxxx enlightened us with...
>> The problem is when the program runs the line "rs.first()" an error
>> occurs and it says "Result Set type is TYPE_FORWARD_ONLY". I must
>> use that line rs.first() in order to continue on after counting the
>> number of results. In another part of my program I check to see if
>> the number of results is equal to 1... if it is, then I want to get
>> information from the database... so, my problem right now is that I
>> can't go to the first row in the ResultSet. How do I eliminate this
>> TYPE_FORWARD_ONLY problem???
> That would depend on whether your DBMS / driver supports anything
> other than forward only result sets.
> Mine didn't.
> I had to make my own resultset object from the orginal resultset that
> implemented that as well as maintained a record count and whatnot. My
> application then used my custom rs object instead of a real ResultSet.
For large results it can be more efficient to execute two queries: one
that counts records and the second one that actually returns results.
> If it IS supported, then you have to specify what you wanted as scroll
> insensitive in the create statement, IIRC.
> See the docs.
Yep, that would be the first thing to try.