Re: MySQL ResultSet - count rows?
- From: Guido Weber <weber.guido@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 10 Dec 2007 18:09:27 +0100
Hi Christoph
as others already pointed out, there is SELECT COUNT (*). The advantage
of that is that the counting can be done in the DB instead of sending
all records from the DBto your app.
But, as you want to read all records anyway, why not store them in a
Java collection (say a List), and use .toArray() to get an array out
of the collection? That way the data has to be fetched only once, and
you need only one DB call.
HTH
Guido
Christoph schrieb:
Hello,.
I am writing the data of a ResultSet object to an array. To declare
the array length, I need to know the number of rows before copying
them - is there a way to read the row count instantly, without having
to iterate anything?
PHP has mysql_count_rows, but I'm not sure what that does internally -
it may just iterate over the data too.
--
Chris
- References:
- MySQL ResultSet - count rows?
- From: Christoph
- MySQL ResultSet - count rows?
- Prev by Date: Re: MySQL ResultSet - count rows?
- Next by Date: Re: MySQL ResultSet - count rows?
- Previous by thread: Re: MySQL ResultSet - count rows?
- Next by thread: Re: MySQL ResultSet - count rows?
- Index(es):
Relevant Pages
|