'm trying to get the number of rows from the result set using following code.
stmt = Connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY
);
System.out.println("Rows returned: " + getResultSetSize(rs));
and my getResultSetSize definition is
public static int getResultSetSize(ResultSet rs) {
int size = 0;
try {
rs.last();
size = rs.getRow();
rs.beforeFirst();
} catch (Exception ex) {
System.out.println("Exception"+ex.getMessage());
}
return size;
}
It's fetching number of rows for one query and for other queries it's throwing an exception Result set type is TYPE_FORWARD_ONLY at sun.jdbc.odbc.JdbcOdbcResultSet.isLast(Unknown Source)
I can print the resultset but I could not number of rows from it. I did not know where I have been wrong.I've even tried with Prepared Statement.But I got same result. Please suggest me a way to get out of this. Thanks in advance.