tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob S." <rsli...@home.com>
Subject RE: Quick JDBC Question
Date Sun, 16 Jul 2000 06:33:47 GMT
> if(rs.next()) {

Goes to first row.

> 	while(rs.next()) {

Goes to second row.

> 		blah blah
> 	}
> }
> else {
> 	blah blah
> 	}
>
> yet, when I do that it skips over the first row entirely.
>
> should I include a count column in the ResultSet perhaps?

So you want it to be "If there are any records returned, iterate through
them."  Examining the JavaDoc for Statement.executeQuery() we know that it
will never be null, so testing that is out.  Statement.getResultSet() says,
"Returns: the current result as a ResultSet; null if the result is an update
count or there are no more results."

if ( (rs = st.getResultSet()) != null ) {

	while ( rs.next() ) {
		blah blah
	}

} else {
	blah blah
}

- r


Mime
View raw message