|
or u
can write
if (rs.next()) {
rs.beforeFirst(); while
(rs.next()) { out.println("username " +
rs.getString("username")); } } else { out.println("No
record found"); }
Vikramjit Singh, Systems Engineer, GTL Ltd.
Ph. 7612929-3140
Hello
Rama,
You
are using rs.next() twice. Thats why it is skipping the first record. Its
enough to use rs.next() in while loop. no need of if
loop.
Thanks & Regards, Surya
----- Original Message -----
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
|