Do a SELECT COUNT(*) FROM ...
query instead.
OR
int size =0;
if (rs != null)
{
rs.last(); // moves cursor to the last row
size = rs.getRow(); // get row id
}
In either of the case, you won’t have to loop over the entire data.
More Related Contents:
- JDBC ResultSet get columns with table alias
- Hours and seconds are lost when storing a date in the database [closed]
- How to get the insert ID in JDBC?
- java.util.Date vs java.sql.Date
- Using setDate in PreparedStatement
- right syntax to use near ‘?’
- Running a .sql script using MySQL with JDBC
- When to close Connection, Statement, PreparedStatement and ResultSet in JDBC
- java.sql.SQLException: Exhausted Resultset
- Most efficient conversion of ResultSet to JSON?
- How to enable logging for SQL statements when using JDBC
- Getting output from dbms_output.get_lines using JDBC
- JDBC driver throws “ResultSet Closed” exception on empty ResultSet
- handling DATETIME values 0000-00-00 00:00:00 in JDBC
- Java – Can’t use ResultSet after connection close
- Timezones in SQL DATE vs java.sql.Date
- SQL prepared statement how to select via multiple possible menu selections?
- Getting an exception ORA-00942: table or view does not exist – when inserting into an existing table
- Class.forName(JDBC_DRIVER) no longer needed?
- How do I use PostgreSQL JSON(B) operators containing a question mark “?” via JDBC
- ResultSet.getString(1) throws java.sql.SQLException: Invalid operation at current cursor position
- Java – Storing SQL statements in an external file [closed]
- ResultSet: Exception: set type is TYPE_FORWARD_ONLY — why?
- How to get the number of columns from a JDBC ResultSet?
- How do I get the row count in JDBC?
- A datetime equivalent in java.sql ? (is there a java.sql.datetime ?)
- Java JDBC connection status
- Convert a Result Set from SQL Array to Array of Strings
- MyBatis executing multiple sql statements in one go, is that possible?
- Database independence through JDBC in java