Numer or rows in result?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Numer or rows in result?

Paul J. Lucas
  I can't seem to find a way to get the number of rows in the
  current result via JDBC.  Is there a way to get the number of
  rows in the result?

  - Paul
Reply | Threaded
Open this post in threaded view
|

Re: Numer or rows in result?

Jeffrey Lichtman

>         I can't seem to find a way to get the number of rows in the
>         current result via JDBC.  Is there a way to get the number of
>         rows in the result?

There is no such method, mainly because it is impossible for a DBMS to know
in advance how many rows will be in the result, except in a few special
cases (e.g. exact match on a unique key). The only way to figure out how
many rows there are is to fetch them all. Most database systems fetch rows
only on demand whenever possible to improve response time, save resources
and improve concurrency.


                        -        Jeff Lichtman
                                 [hidden email]
                                 Check out Swazoo Koolak's Web Jukebox at
                                 http://swazoo.com/ 

Reply | Threaded
Open this post in threaded view
|

Re: Numer or rows in result?

Shreyas Kaushik
In reply to this post by Paul J. Lucas
Hi Paul ,

Yes. Right now there is no way this can be done. Two options depending
on the type of the ResultSet you have,

~ scroll through and calculate the size, the counter way.
~ Populate a rowset and call the size() method there.

~ Shreyas

Paul J. Lucas wrote:

>     I can't seem to find a way to get the number of rows in the
>     current result via JDBC.  Is there a way to get the number of
>     rows in the result?
>
>     - Paul

Reply | Threaded
Open this post in threaded view
|

Re: Numer or rows in result?

Philip Wilder
In reply to this post by Paul J. Lucas
Paul J. Lucas wrote:

>     I can't seem to find a way to get the number of rows in the
>     current result via JDBC.  Is there a way to get the number of
>     rows in the result?
>
>     - Paul
>
http://forum.java.sun.com/thread.jspa?threadID=618353&tstart=136

Philip


Reply | Threaded
Open this post in threaded view
|

Re: Numer or rows in result?

Paul J. Lucas
In reply to this post by Shreyas Kaushik
On Tue, 17 May 2005, Shreyas Kaushik wrote:

> ~ Populate a rowset and call the size() method there.

  Could you either elaborate on that or provide a pointer?
  Thanks.

  - Paul