Presumably, "qds.fetchRecords()" returns what -- a Vector of Hashtables (or
Village objects) or something? That's the same thing as calling ResultSet.next()
until the ResultSet is exhausted, so that doesn't solve his problem. Plus, what
if this is going to be a monumental number of records that is apt to blow out
memory? Do you have a way to iterate through the ResultSet?

In any case, you could try a "select count" prior to executing your statement. I
don't know if there is a JDBC command that lets you query the ResultSet for the
number of rows it is going to return (but hasn't yet).




jon * wrote:

> > Hi! In jdbc, how to know the number of rows a query retrieved? Is there
> > a good way other than using ResultSet.next()?
>
> Using Village, I do this:
>
> QueryDataSet qds = new QueryDataSet(connection, "select * from table");
> qds.fetchRecords();
>
> int size = qds.size();
>
> qds.close();
>
> the int size will have the number of records fetched. you can also
> (optionally) pass the number of records (as well as the starting point) that
> you want to fetch to the fetchRecords() method. example: that is cool if you
> only want to fetch the first 20 records starting at record 10.
>
> <http://www.working-dogs.com/village/>
>
> -jon
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to