You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by "Paul J. Lucas" <pa...@mac.com> on 2005/05/16 19:35:40 UTC

Numer or rows in result?

 	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

Re: Numer or rows in result?

Posted by Jeffrey Lichtman <sw...@rcn.com>.
>         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
                                 swazoo@rcn.com
                                 Check out Swazoo Koolak's Web Jukebox at
                                 http://swazoo.com/ 


Re: Numer or rows in result?

Posted by Philip Wilder <05...@acadiau.ca>.
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



Re: Numer or rows in result?

Posted by "Paul J. Lucas" <pa...@mac.com>.
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

Re: Numer or rows in result?

Posted by Shreyas Kaushik <Sh...@Sun.COM>.
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