LeanMoreTryMore
asked on
detect no return record (Simple quetion. but need help)
Very simple question as I have forgotten to bring my java book.
My question is how to i detect no record return from the query.
See my code below
String IsReqNoExistSQL = "SELECT 'Y' FROM system_conf " +
" WHERE req_no = " + "'" + reqNo + "'" ;
System.out.println("IsReqN oExistSQL: " + IsReqNoExistSQL);
Statement SessionStatement = dbConn.createStatement();
ResultSet SessionRS = SessionStatement.executeQu ery(IsReqN oExistSQL) ;
SessionRS.next(); <======= cause error if no record return from the query
recordExist = SessionRS.getString(1);
SessionStatement.close();
My question is how to i detect no record return from the query.
See my code below
String IsReqNoExistSQL = "SELECT 'Y' FROM system_conf " +
" WHERE req_no = " + "'" + reqNo + "'" ;
System.out.println("IsReqN
Statement SessionStatement = dbConn.createStatement();
ResultSet SessionRS = SessionStatement.executeQu
SessionRS.next(); <======= cause error if no record return from the query
recordExist = SessionRS.getString(1);
SessionStatement.close();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.