Dear Rama,
 
   To know the number of records returned, use the following two lines of code.
 
   rs.last(); //moves the control to the last record
   int count = rs.getRow(); //gets the row count
 
Thanks and Regards,
Surya.
----- Original Message -----
From: Rama
Sent: Thursday, January 31, 2002 11:53 AM
Subject: JDBC

Hi,

I wonder how to know if the query returned is empty or not.

I use this code:
ResultSet rs = stmt.executeQuery("SELECT * FROM user");

if (rs.next()) {
  while (rs.next()) {
    out.println("username " + rs.getString("username"));
  }
}
else {
  out.println("No record found");
}


but it always skips the first line of the record.

1. How to know if the query returned is empty or not.

2. Also, is there any way to know how many records returned?


Thank you,


Rama



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to