ResultSet reading

In this chapter you will learn:

  1. Read data from ResultSet

Viewing a Result Set

The ResultSet interface contains methods for getting the data of the current row. Each data type has its corresponding method in ResultSet interface. And each get method has two versions:

  • Get by a column name.
  • Get by a column index.

For example,

  • public int getInt(String columnName)
    Returns the int in the current row for column named columnName
  • public int getInt(int columnIndex)
    Returns the int in the current row for specified column index.

The column index starts at 1, not 0.

The result set maintains a reference to the current row called the cursor. The cursor is positioned before the first row when a result set is created. When a result set's next() method is called, the cursor moves to the first row of the resultset, and that row becomes the current row.

Next chapter...

What you will learn in the next chapter:

  1. Get data from ResultSet by column name
Home » Java Tutorial » Statements, ResultSet, Exception, Warning

Statement

    Three types of statements
    Statement interface
    Insert
    Delete records
    Drop a table
    Batch operation

PreparedStatement

    PreparedStatement
    Insert
    Delete
    Update with parameters
    Batch operation
    ParameterMetaData
    Fetch size
    Set null vaue

CallableStatement

    CallableStatement

ResultSet

    ResultSet
    ResultSet Type
    ResultSet Concurrency
    Create a ResultSet
    ResultSet reading
    ResultSet get by column name
    ResultSet get column by index
    ResultSet next row
    ResultSet table row count
    ResultSet navigation
    ResultSet cursor forward and backward
    ResultSet first
    ResultSet last
    ResultSet after last
    ResultSet before first
    ResultSet absolute(2)
    ResultSet absolute(-1)
    ResultSet relative(-2)
    ResultSet relative(-2)
    ResultSet update
    Column Names
    Column count
    Column Characteristics

ResultSetMetaData

    Column Names
    Column count
    Column Characteristics

SQL Exception, SQL Warning

    SQL Exception
    SQLException information
    Chaining SQLExceptions
    Connection Warning
    PreparedStatement SQLWarning
    Statement SQLWarning
    ResultSet warning
    SQLWarning information