Retrieve a rowcount from a ResultSet : Statement « Database « Java Tutorial






import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class Main {
  public static void main(String[] argv) throws Exception {
    Connection conn = null;
    Statement s = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
        ResultSet.CONCUR_READ_ONLY);
    ResultSet r = s
        .executeQuery("SELECT * FROM employee");
    r.last();
    int count = r.getRow();
    r.beforeFirst();
  }
}








20.5.Statement
20.5.1.Change the fetch size on the result set
20.5.2.Get the fetch size of a statement
20.5.3.Set the fetch size on the statement
20.5.4.Retrieving All Rows from a Database Table
20.5.5.Getting Column Names from a database table in Java
20.5.6.Retrieve a rowcount from a ResultSet
20.5.7.Setting the Number of Rows to Prefetch When Executing a SQL Query
20.5.8.Create a result set
20.5.9.Creating a Database Table called my_table with one column, col_string, which holds strings.
20.5.10.Deleting a Database Table called my_table from a database.
20.5.11.Inserting a Row into a Database Table
20.5.12.Inserting a Row into a Database Table Using a Prepared Statement
20.5.13.Deleting a Row from a Database Table
20.5.14.Statement Batch Update