Class ResultSetWrappingSqlRowSet

java.lang.Object
org.springframework.jdbc.support.rowset.ResultSetWrappingSqlRowSet
All Implemented Interfaces:
Serializable, SqlRowSet

public class ResultSetWrappingSqlRowSet extends Object implements SqlRowSet
The common implementation of Spring's SqlRowSet interface, wrapping a ResultSet, catching any SQLExceptions and translating them to a corresponding Spring InvalidResultSetAccessException.

The passed-in ResultSet should already be disconnected if the SqlRowSet is supposed to be usable in a disconnected fashion. This means that you will usually pass in a javax.sql.rowset.CachedRowSet, which implements the ResultSet interface.

Note: Since JDBC 4.0, it has been clarified that any methods using a String to identify the column should be using the column label. The column label is assigned using the ALIAS keyword in the SQL query string. When the query doesn't use an ALIAS, the default label is the column name. Most JDBC ResultSet implementations follow this pattern, but there are exceptions such as the com.sun.rowset.CachedRowSetImpl class which only uses the column name, ignoring any column labels. ResultSetWrappingSqlRowSet will translate column labels to the correct column index to provide better support for com.sun.rowset.CachedRowSetImpl which is the default implementation used by JdbcTemplate when working with RowSets.

Note: This class implements the java.io.Serializable marker interface through the SqlRowSet interface, but is only actually serializable if the disconnected ResultSet/RowSet contained in it is serializable. Most CachedRowSet implementations are actually serializable, so serialization should usually work.

Since:
1.2
Author:
Thomas Risberg, Juergen Hoeller
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new ResultSetWrappingSqlRowSet for the given ResultSet.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    absolute(int row)
    Move the cursor to the given row number in the row set, just after the last row.
    void
    Move the cursor to the end of this row set.
    void
    Move the cursor to the front of this row set, just before the first row.
    int
    findColumn(String columnLabel)
    Map the given column label to its column index.
    boolean
    Move the cursor to the first row of this row set.
    getBigDecimal(int columnIndex)
    Retrieve the value of the indicated column in the current row as a BigDecimal object.
    getBigDecimal(String columnLabel)
    Retrieve the value of the indicated column in the current row as a BigDecimal object.
    boolean
    getBoolean(int columnIndex)
    Retrieve the value of the indicated column in the current row as a boolean.
    boolean
    getBoolean(String columnLabel)
    Retrieve the value of the indicated column in the current row as a boolean.
    byte
    getByte(int columnIndex)
    Retrieve the value of the indicated column in the current row as a byte.
    byte
    getByte(String columnLabel)
    Retrieve the value of the indicated column in the current row as a byte.
    getDate(int columnIndex)
    Retrieve the value of the indicated column in the current row as a Date object.
    getDate(int columnIndex, Calendar cal)
    Retrieve the value of the indicated column in the current row as a Date object.
    getDate(String columnLabel)
    Retrieve the value of the indicated column in the current row as a Date object.
    getDate(String columnLabel, Calendar cal)
    Retrieve the value of the indicated column in the current row as a Date object.
    double
    getDouble(int columnIndex)
    Retrieve the value of the indicated column in the current row as a Double object.
    double
    getDouble(String columnLabel)
    Retrieve the value of the indicated column in the current row as a Double object.
    float
    getFloat(int columnIndex)
    Retrieve the value of the indicated column in the current row as a float.
    float
    getFloat(String columnLabel)
    Retrieve the value of the indicated column in the current row as a float.
    int
    getInt(int columnIndex)
    Retrieve the value of the indicated column in the current row as an int.
    int
    getInt(String columnLabel)
    Retrieve the value of the indicated column in the current row as an int.
    long
    getLong(int columnIndex)
    Retrieve the value of the indicated column in the current row as a long.
    long
    getLong(String columnLabel)
    Retrieve the value of the indicated column in the current row as a long.
    Retrieve the meta-data, i.e.
    getNString(int columnIndex)
    Retrieve the value of the indicated column in the current row as a String (for NCHAR, NVARCHAR, LONGNVARCHAR columns).
    getNString(String columnLabel)
    Retrieve the value of the indicated column in the current row as a String (for NCHAR, NVARCHAR, LONGNVARCHAR columns).
    getObject(int columnIndex)
    Retrieve the value of the indicated column in the current row as an Object.
    <T> T
    getObject(int columnIndex, Class<T> type)
    Retrieve the value of the indicated column in the current row as an Object.
    getObject(int columnIndex, Map<String,Class<?>> map)
    Retrieve the value of the indicated column in the current row as an Object.
    getObject(String columnLabel)
    Retrieve the value of the indicated column in the current row as an Object.
    <T> T
    getObject(String columnLabel, Class<T> type)
    Retrieve the value of the indicated column in the current row as an Object.
    getObject(String columnLabel, Map<String,Class<?>> map)
    Retrieve the value of the indicated column in the current row as an Object.
    final ResultSet
    Return the underlying ResultSet (usually a javax.sql.rowset.CachedRowSet).
    int
    Retrieve the current row number.
    short
    getShort(int columnIndex)
    Retrieve the value of the indicated column in the current row as a short.
    short
    getShort(String columnLabel)
    Retrieve the value of the indicated column in the current row as a short.
    getString(int columnIndex)
    Retrieve the value of the indicated column in the current row as a String.
    getString(String columnLabel)
    Retrieve the value of the indicated column in the current row as a String.
    getTime(int columnIndex)
    Retrieve the value of the indicated column in the current row as a Time object.
    getTime(int columnIndex, Calendar cal)
    Retrieve the value of the indicated column in the current row as a Time object.
    getTime(String columnLabel)
    Retrieve the value of the indicated column in the current row as a Time object.
    getTime(String columnLabel, Calendar cal)
    Retrieve the value of the indicated column in the current row as a Time object.
    getTimestamp(int columnIndex)
    Retrieve the value of the indicated column in the current row as a Timestamp object.
    getTimestamp(int columnIndex, Calendar cal)
    Retrieve the value of the indicated column in the current row as a Timestamp object.
    getTimestamp(String columnLabel)
    Retrieve the value of the indicated column in the current row as a Timestamp object.
    getTimestamp(String columnLabel, Calendar cal)
    Retrieve the value of the indicated column in the current row as a Timestamp object.
    boolean
    Retrieve whether the cursor is after the last row of this row set.
    boolean
    Retrieve whether the cursor is before the first row of this row set.
    boolean
    Retrieve whether the cursor is on the first row of this row set.
    boolean
    Retrieve whether the cursor is on the last row of this row set.
    boolean
    Move the cursor to the last row of this row set.
    boolean
    Move the cursor to the next row.
    boolean
    Move the cursor to the previous row.
    boolean
    relative(int rows)
    Move the cursor a relative number of rows, either positive or negative.
    boolean
    Report whether the last column read had a value of SQL NULL.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait