tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kurt B. Pruenner" <l...@gmx.at>
Subject Re: Quick JDBC Question
Date Sun, 16 Jul 2000 11:46:28 GMT
Luis Andrei Cobo wrote:
> How can I tell if I resultset returns 0 rows?
> 
> i try this:
> 
> if(rs.next()) {
>         while(rs.next()) {
>                 blah blah
>         }
> }
> else {
>         blah blah
>         }
> 
> yet, when I do that it skips over the first row entirely.

Of course it does; you're calling rs.next() twice in a row... :)

As I'm using an older version of Tomcat in conjunction with a MySQL JDBC
driver that hardly supports anything, I've gone and used the following:

if (rs.next())
{
  do
  {
    // blah blah
  }
  while (rs.next())
}
else
 // blah blah

As you see, it's almost the same code you used, but with a twist... :)

-- 
Kurt Pruenner - Haendelstrasse 17 - 4020 Linz - Austria
http://www.mp3.com/Leak - http://www.ssw.uni-linz.ac.at

np: Gas - Track 5 (Pop)

Mime
View raw message