Normally, when we want to retrieve a value from our database which is present in the table, we call the appropriate method of ResultSet and pass it the column name which we want to retrieve.
ResultSet rs= stmt.executeQuery("select name from db.persons where school ='"+sch+"'");
int count= rs.getString("person_name");
But when we want to get a count of rows (or fields) in a particular column (we use the SQL COUNT function), how do we retrieve the result. What argument should I pass in the rs.getInt() method in the following piece of code?
ResultSet rs= stmt.executeQuery("select count(name) from db.persons where school ='"+sch+"'");
int count= rs.getInt( ????? );