Re: MySQL ResultSet - count rows?



On Dec 10, 10:34 am, Christoph <christoph.bursc...@xxxxxxxxx> wrote:
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

How about initing a CachedRowSet object from your result set? (http://
java.sun.com/j2se/1.5.0/docs/api/javax/sql/rowset/CachedRowSet.html)

you could then avail yourself of the size() method - and with just a
single pass.

T
.



Relevant Pages

  • Re: MySQL ResultSet - count rows?
    ... the array length, I need to know the number of rows before copying ... it may just iterate over the data too. ... So in that sense PHP and JDBC are identical. ...
    (comp.lang.java.databases)
  • Re: MySQL ResultSet - count rows?
    ... the array length, I need to know the number of rows before copying ... it may just iterate over the data too. ... At least incrementing the pointer is not a very expensive action. ...
    (comp.lang.java.databases)
  • Re: MySQL ResultSet - count rows?
    ... I am writing the data of a ResultSet object to an array. ... To declare ... it may just iterate over the data too. ...
    (comp.lang.java.databases)
  • Re: MySQL ResultSet - count rows?
    ... I am writing the data of a ResultSet object to an array. ... To declare ... it may just iterate over the data too. ...
    (comp.lang.java.databases)
  • Re: MySQL ResultSet - count rows?
    ... I am writing the data of a ResultSet object to an array. ... To declare ... it may just iterate over the data too. ...
    (comp.lang.java.databases)