i m working in jsp and i m executing a query like :
String var="select * from reservation where starting_time='"+i+"' and
allocation_no='"+j+"'";
ResultSet rs = st1.executeQuery(var);
now i want to check whether rs contains some value in it or not.
so what syntax should i use for this...
i want to use it for if-statement like....
if (rs is null)
execute this
else
execute this
please help....
Murray - 07 Jun 2005 11:38 GMT
> i m working in jsp and i m executing a query like :
>
[quoted text clipped - 15 lines]
>
> please help....
if (rs.next()) {
doStuff
} else {
doOtherStuff
}
Manish - 08 Jun 2005 06:09 GMT
if(rs !=null )..If u want to check resultset is null or not.
or
rs.wasNull() ..Reports whether the last column read had a value of SQL
NULL.
Hal Rosser - 11 Jun 2005 03:46 GMT
I believe you can use the isAfterLast() method and the isBeforeFirst()
method of the Resultset. If both return true, then no records are in the
resultset.
if (rs.isBeforeFirst() && rs.isAfterLast()){
// rs is empty
}
> i m working in jsp and i m executing a query like :
>
[quoted text clipped - 15 lines]
>
> please help....