Resultset rs=stmt.executeQuery(\"select count(*) from feedsca group by score order by score\");
Using the above java code above, am retrieving the
You need to call rs.next() before accessing the first row.
Typically, you will iterate over the result set like this:
ResultSet rs = ...;
while (rs.next()) {
...
}
Update: Note that SELECT COUNT(*) ... returns only one field per row, which is the count. You may have several rows, but each row will have only one field, which has index 1. You need to iterate through the rows to get all the counts:
while (rs.next()) {
System.out.println(rs.getInt(1));
}
Yet another update: It's bad to assume that your query will always return only 3 rows. However, if you are absolutely sure of this, then you can just call next 3 times manually:
long l1, l2, l3;
rs.next();
l1 = rs.getLong(1);
rs.next();
l2 = rs.getLong(1);
rs.next();
l3 = rs.getLong(1);
pw.printf(rowFormat, l1,"0",l2,l3);