if the "stmt" is wrong ,the "rs" will be null. And your programe will throw a fatal error.
so ,u must write as follows:
if(rs!=null)
{
while(rs.next())
{
//specific operation...
}
}
java.sql.Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM Table1");
while (rs.next()) {
// retrieve and print the values for the current row
int i = rs.getInt("a");
String s = rs.getString("b");
float f = rs.getFloat("c");
System.out.println("ROW = " + i + " " + s + " " + f);
}