Top Description Fields Constructors Methods
org.springframework.jdbc.support.rowset

public Class ResultSetWrappingSqlRowSet

extends Object
implements SqlRowSet
Class Inheritance
All Implemented Interfaces
org.springframework.jdbc.support.rowset.SqlRowSet, java.io.Serializable
Imports
java.math.BigDecimal, java.sql.Date, .ResultSet, .ResultSetMetaData, .SQLException, .Time, .Timestamp, java.util.Calendar, .Collections, .Map, org.springframework.jdbc.InvalidResultSetAccessException, org.springframework.lang.Nullable, org.springframework.util.CollectionUtils

The default implementation of Spring's 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.springframework.jdbc.core.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.

Authors
Thomas Risberg, Juergen Hoeller
Since
1.2
See Also
java.sql.ResultSet, javax.sql.rowset.CachedRowSet, org.springframework.jdbc.core.JdbcTemplate#queryForRowSet

Field Summary

Modifier and TypeField and Description
private final Map<String, Integer>
private final ResultSet
private final SqlRowSetMetaData
private static final long
serialVersionUID

use serialVersionUID from Spring 1.2 for interoperability.

Constructor Summary

AccessConstructor and Description
public
ResultSetWrappingSqlRowSet(ResultSet
a disconnected ResultSet to wrap (usually a javax.sql.rowset.CachedRowSet)
resultSet
)

Create a new ResultSetWrappingSqlRowSet for the given ResultSet.

Method Summary

Modifier and TypeMethod and Description
public boolean
absolute(int
the number of the row where the cursor should move
row
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.absolute.

Move the cursor to the given row number in the row set, just after the last row.
public void
afterLast()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.afterLast.

Move the cursor to the end of this row set.
public void
beforeFirst()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.beforeFirst.

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.springframework.jdbc.support.rowset.SqlRowSet.findColumn.

Map the given column label to its column index.
public boolean
first()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.first.

Move the cursor to the first row of this row set.
public BigDecimal
getBigDecimal(int
the column index
columnIndex
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getBigDecimal.

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.springframework.jdbc.support.rowset.SqlRowSet.getBigDecimal.

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.springframework.jdbc.support.rowset.SqlRowSet.getBoolean.

Retrieve the value of the indicated column in the current row as a boolean.
public boolean
getBoolean(String
the column label
columnLabel
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getBoolean.

Retrieve the value of the indicated column in the current row as a boolean.
public byte
getByte(int
the column index
columnIndex
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getByte.

Retrieve the value of the indicated column in the current row as a byte.
public byte
getByte(String
the column label
columnLabel
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getByte.

Retrieve the value of the indicated column in the current row as a byte.
public Date
getDate(int
the column index
columnIndex
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getDate.

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.springframework.jdbc.support.rowset.SqlRowSet.getDate.

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.springframework.jdbc.support.rowset.SqlRowSet.getDate.

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.springframework.jdbc.support.rowset.SqlRowSet.getDate.

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.springframework.jdbc.support.rowset.SqlRowSet.getDouble.

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.springframework.jdbc.support.rowset.SqlRowSet.getDouble.

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.springframework.jdbc.support.rowset.SqlRowSet.getFloat.

Retrieve the value of the indicated column in the current row as a float.
public float
getFloat(String
the column label
columnLabel
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getFloat.

Retrieve the value of the indicated column in the current row as a float.
public int
getInt(int
the column index
columnIndex
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getInt.

Retrieve the value of the indicated column in the current row as an int.
public int
getInt(String
the column label
columnLabel
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getInt.

Retrieve the value of the indicated column in the current row as an int.
public long
getLong(int
the column index
columnIndex
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getLong.

Retrieve the value of the indicated column in the current row as a long.
public long
getLong(String
the column label
columnLabel
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getLong.

Retrieve the value of the indicated column in the current row as a long.
public final SqlRowSetMetaData
getMetaData()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getMetaData.

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.springframework.jdbc.support.rowset.SqlRowSet.getNString.

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.springframework.jdbc.support.rowset.SqlRowSet.getNString.

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.springframework.jdbc.support.rowset.SqlRowSet.getObject.

Retrieve the value of the indicated column in the current row as an Object.
public Object
getObject(String
the column label
columnLabel
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getObject.

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.springframework.jdbc.support.rowset.SqlRowSet.getObject.

Retrieve the value of the indicated column in the current row as an Object.
public Object
getObject(String
the column label
columnLabel
,
Map<String, Class<?>>
a Map object containing the mapping from SQL types to Java types
map
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getObject.

Retrieve the value of the indicated column in the current row as an Object.
public <T> T
getObject(int
the column index
columnIndex
,
Class<T>
the Java type to convert the designated column to
type
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getObject.

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.springframework.jdbc.support.rowset.SqlRowSet.getObject.

Retrieve the value of the indicated column in the current row as an Object.
public final ResultSet
getResultSet()

Return the underlying ResultSet (usually a javax.sql.rowset.CachedRowSet).

public int
getRow()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getRow.

Retrieve the current row number.
public short
getShort(int
the column index
columnIndex
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getShort.

Retrieve the value of the indicated column in the current row as a short.
public short
getShort(String
the column label
columnLabel
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getShort.

Retrieve the value of the indicated column in the current row as a short.
public String
getString(int
the column index
columnIndex
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getString.

Retrieve the value of the indicated column in the current row as a String.
public String
getString(String
the column label
columnLabel
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getString.

Retrieve the value of the indicated column in the current row as a String.
public Time
getTime(int
the column index
columnIndex
)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.getTime.

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.springframework.jdbc.support.rowset.SqlRowSet.getTime.

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.springframework.jdbc.support.rowset.SqlRowSet.getTime.

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.springframework.jdbc.support.rowset.SqlRowSet.getTime.

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.springframework.jdbc.support.rowset.SqlRowSet.getTimestamp.

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.springframework.jdbc.support.rowset.SqlRowSet.getTimestamp.

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.springframework.jdbc.support.rowset.SqlRowSet.getTimestamp.

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.springframework.jdbc.support.rowset.SqlRowSet.getTimestamp.

Retrieve the value of the indicated column in the current row as a Timestamp object.
public boolean
isAfterLast()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.isAfterLast.

Retrieve whether the cursor is after the last row of this row set.
public boolean
isBeforeFirst()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.isBeforeFirst.

Retrieve whether the cursor is before the first row of this row set.
public boolean
isFirst()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.isFirst.

Retrieve whether the cursor is on the first row of this row set.
public boolean
isLast()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.isLast.

Retrieve whether the cursor is on the last row of this row set.
public boolean
last()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.last.

Move the cursor to the last row of this row set.
public boolean
next()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.next.

Move the cursor to the next row.
public boolean
previous()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.previous.

Move the cursor to the previous row.
public boolean
relative(int rows)

Implements org.springframework.jdbc.support.rowset.SqlRowSet.relative.

Move the cursor a relative number of rows, either positive or negative.
public boolean
wasNull()

Implements org.springframework.jdbc.support.rowset.SqlRowSet.wasNull.

Report whether the last column read had a value of SQL NULL.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait