Retrieve a rowcount from a ResultSet : ResultSet « Database SQL JDBC « Java

Retrieve a rowcount from a ResultSet

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 r = s
        .executeQuery("SELECT * FROM employee");
    int count = r.getRow();


Related examples in the same category

1.ResultSet getter Methods
2.ResultSet Update Methods
3.Get Column Count In ResultSet
4.Get available ResultSet types
5.Get BLOB data from resultset
6.ResultSet Update
7.Results Decorator XML
8.Results Decorator Text
9.Results Decorator SQL
10.Print ResultSet in HTML
11.Demonstrate simple use of the CachedRowSet
12.Metadata for ResultSet
13.Scrollable ResultSet
14.Concurrency in ResultSet
15.SQL statement: ResultSet and ResultSetMetaData
16.Output data from table
17.Convert a ResultSet to XML
18.Wraps a ResultSet in an Iterator.
19.Wraps a ResultSet to trim strings returned by the getString() and getObject() methods.
20.Decorates a ResultSet with checks for a SQL NULL value on each getXXX method.