how to ckeck whether the executeQuery function select 1 row or not

Hi,

Can somebody tell me how to check if 1 row got selected

and if not ( there is no row in table for that query data) by using executeQuery function

eg. ResultSet resultSet=stmt.executeQuery(select * from emp where name = 'ray');

in case if this query does not return any row then i want to display there are no records

else i want todisplay 1 row select

[394 byte] By [harsh_gandhia] at [2007-10-2 3:56:25]
# 1

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE2");

if (rs.next()) {

//code to process result set

} else {

//code to send message that result set is empty

}

tolmanka at 2007-7-15 23:17:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...