Hi people,
I want to have an if statement in my servlet that if no results are found from database i print out an error to a html page. Im not to sure how to do this though..See my attempt in code below, can someone tell me what im doing wrong..I know its prob a stupid error but im prety new to java so please excuse
try
{
out.println("JOBID --- SECTOR --- LOCATION --- SALARY" +
" --- EMAIL --- DESCRIPTION --- COMPANY <br>");
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM FMC_JOBS WHERE SECTOR ='"+thisSector+ "'" +
" AND LOCATION = '"+Location+"'" );
while (rs.next())
out.println( rs.getString("JOBID") + "---" + rs.getString("SECTOR") + "--- " +
rs.getString("LOCATION") + "--- " + rs.getString("SALARY") + "--- " + rs.getString("EMAIL")
+ "--- "+rs.getString("DESCRIPTION") + "---" + rs.getString("COMPANY") +"<br><br>");
}
catch (Exception e) {
out.println("<BR>An error has occurred during the Statement/ResultSet phase.");
}
if (rs.equals("")){
out.println("Sorry, No results returned.");
}