How to check whether the Resultset is empty or not ?

I wanna check whether my Result set is empty or not ( I don't want the no of rows it contains..) i'm using this function...

boolean result=myResultSet.isAfterLast() | myResultSet.isBeforeFirst() ;

if (result == true)

{//Result Set is populated

}

else

{//ResultSet Blank

}

Is it ok to do like this ? Or is there any other functanality to do this, since in big appl..i'm using it more than 10-15 times & it's working fine evrywhere except for one jsp where it is returing TRUE everytime ...

Help Appreciated !!

[598 byte] By [romit_k] at [2007-9-26 1:37:05]
# 1
I would simply do:boolean filled = rs.next();if( filled ){ // retrieve column values...}
Hartmut at 2007-6-29 2:23:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

try,

rs = pstmt.executeQuery();

boolean b = false;

if( b = rs.next() ) {

while( b ) {

//... rs.getXXX( YYY );

b = rs.next();

}

}

else {

//...empty rs processing

}

or,

ResultSet rs = ps.executeQuery();

if(rs.next()) {

do {

System.out.println(rs.getString(1));

} while(rs.next());

} else {

System.out.println('empty result set');

}

but I usually avoid using do...while although this may be an exception.

mchan0 at 2007-6-29 2:23:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...