Hi, Silvia,

(A) If you are counting the number of records in a table, use:
query = "SELECT count(*) FROM theTable "
... execute the query, and put the result in resultSet rs ...
then, rs.getInt(1) gives you the number of records in the table.

(B) If you want to know the number of records in your resultSet,
you may use:

int count = 0 ;

while(rs.next())  // rs is the resultSet
{
  count++ ;
}
at the end of the loop, count is the number of records.

(C) If you want to know the number of records in your resultSet,
you may also use:

int count = rs.getFatchSize();

which gives you the count of the resultSet.

I think (B) is only good for small number of results. (C) should be
good in any cases.

Regards,

Debbie
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
Silvia Gaspar
Sent: Wednesday, August 09, 2000 5:56 AM
To: [EMAIL PROTECTED]
Subject: Number of Records
Importance: High


        What function give us the number of records retrieved by a query?
I'm using JDBC.



Regards,
----------------------------------------------------------------------------
-------------------------------
Compta - Equipamentos e Servi�os de inform�tica, S.A

S�lvia Gaspar
Engenharia de Sistemas e Aplica��es
Implementa��o
Consultora  S�nior
*  TEL: +351.21. 350 14 00
*  Directo:     +351.21. 313 55 51
*    Fax:       +351.21.352 02 02
* e-mail:    [EMAIL PROTECTED]
* WWW:      www.compta.pt

___________________________________________________________________________
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