SqlRowSet interface, wrapping a
java.sql.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
org. 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.
java.sql.ResultSet , javax.sql.rowset.CachedRowSet , org.springframework.jdbc.core.JdbcTemplate#queryForRowSet
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private final ResultSet | |
| private final SqlRowSetMetaData | |
| private static final long | serialVersionUID
use serialVersionUID from Spring 1.2 for interoperability. |
| Access | Constructor and Description |
|---|---|
| public | ResultSetWrappingSqlRowSet(ResultSet
a disconnected ResultSet to wrap
(usually a resultSet)javax.sql.rowset.CachedRowSet)Create a new |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | absolute(int
the number of the row where the cursor should move row)Implements org. Move the cursor to the given row number in the row set, just after the last row. |
| public void | afterLast()
Implements org. Move the cursor to the end of this row set. |
| public void | beforeFirst()
Implements org. Move the cursor to the front of this row set, just before the first row. |
| public int | findColumn(String
the name of the column columnLabel)Implements org. Map the given column label to its column index. |
| public boolean | first()
Implements org. Move the cursor to the first row of this row set. |
| public BigDecimal | getBigDecimal(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as a BigDecimal object. |
| public BigDecimal | getBigDecimal(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as a BigDecimal object. |
| public boolean | getBoolean(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as a boolean. |
| public boolean | getBoolean(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as a boolean. |
| public byte | getByte(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as a byte. |
| public byte | getByte(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as a byte. |
| public Date | getDate(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as a Date object. |
| public Date | getDate(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as a Date object. |
| public Date | getDate(int
the column index columnIndex, Calendar the Calendar to use in constructing the Date cal)Implements org. Retrieve the value of the indicated column in the current row as a Date object. |
| public Date | getDate(String
the column label columnLabel, Calendar the Calendar to use in constructing the Date cal)Implements org. Retrieve the value of the indicated column in the current row as a Date object. |
| public double | getDouble(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as a Double object. |
| public double | getDouble(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as a Double object. |
| public float | getFloat(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as a float. |
| public float | getFloat(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as a float. |
| public int | getInt(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as an int. |
| public int | getInt(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as an int. |
| public long | getLong(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as a long. |
| public long | getLong(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as a long. |
| public final SqlRowSetMetaData | getMetaData()
Implements org. Retrieve the meta-data, i.e. number, types and properties for the columns of this row set. |
| public String | getNString(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as a String (for NCHAR, NVARCHAR, LONGNVARCHAR columns). |
| public String | getNString(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as a String (for NCHAR, NVARCHAR, LONGNVARCHAR columns). |
| public Object | getObject(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as an Object. |
| public Object | getObject(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as an Object. |
| public Object | getObject(int
the column index columnIndex, Map<String, Class<?>> a Map object containing the mapping from SQL types to Java types map)Implements org. Retrieve the value of the indicated column in the current row as an Object. |
| public Object | |
| public <T> T | getObject(int
the column index columnIndex, Class<T> the Java type to convert the designated column to type)Implements org. Retrieve the value of the indicated column in the current row as an Object. |
| public <T> T | getObject(String
the column label columnLabel, Class<T> the Java type to convert the designated column to type)Implements org. Retrieve the value of the indicated column in the current row as an Object. |
| public final ResultSet | |
| public int | getRow()
Implements org. Retrieve the current row number. |
| public short | getShort(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as a short. |
| public short | getShort(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as a short. |
| public String | getString(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as a String. |
| public String | getString(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as a String. |
| public Time | getTime(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as a Time object. |
| public Time | getTime(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as a Time object. |
| public Time | getTime(int
the column index columnIndex, Calendar the Calendar to use in constructing the Date cal)Implements org. Retrieve the value of the indicated column in the current row as a Time object. |
| public Time | getTime(String
the column label columnLabel, Calendar the Calendar to use in constructing the Date cal)Implements org. Retrieve the value of the indicated column in the current row as a Time object. |
| public Timestamp | getTimestamp(int
the column index columnIndex)Implements org. Retrieve the value of the indicated column in the current row as a Timestamp object. |
| public Timestamp | getTimestamp(String
the column label columnLabel)Implements org. Retrieve the value of the indicated column in the current row as a Timestamp object. |
| public Timestamp | getTimestamp(int
the column index columnIndex, Calendar the Calendar to use in constructing the Date cal)Implements org. Retrieve the value of the indicated column in the current row as a Timestamp object. |
| public Timestamp | getTimestamp(String
the column label columnLabel, Calendar the Calendar to use in constructing the Date cal)Implements org. Retrieve the value of the indicated column in the current row as a Timestamp object. |
| public boolean | isAfterLast()
Implements org. Retrieve whether the cursor is after the last row of this row set. |
| public boolean | isBeforeFirst()
Implements org. Retrieve whether the cursor is before the first row of this row set. |
| public boolean | isFirst()
Implements org. Retrieve whether the cursor is on the first row of this row set. |
| public boolean | isLast()
Implements org. Retrieve whether the cursor is on the last row of this row set. |
| public boolean | last()
Implements org. Move the cursor to the last row of this row set. |
| public boolean | next()
Implements org. Move the cursor to the next row. |
| public boolean | previous()
Implements org. Move the cursor to the previous row. |
| public boolean | relative(int rows)
Implements org. Move the cursor a relative number of rows, either positive or negative. |
| public boolean | wasNull()
Implements org. Report whether the last column read had a value of SQL |