Class ResultSetWrappingSqlRowSet
- All Implemented Interfaces:
- Serializable,- SqlRowSet
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 new pattern but there are
 exceptions such as the com.sun.rowset.CachedRowSetImpl class which only uses
 the column name, ignoring any column labels. As of Spring 3.0.5, ResultSetWrappingSqlRowSet
 will translate column labels to the correct column index to provide better support for the
 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 this should usually work out.
- Since:
- 1.2
- Author:
- Thomas Risberg, Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionResultSetWrappingSqlRowSet(ResultSet resultSet) Create a new ResultSetWrappingSqlRowSet for the given ResultSet.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanabsolute(int row) Move the cursor to the given row number in the row set, just after the last row.voidMove the cursor to the end of this row set.voidMove the cursor to the front of this row set, just before the first row.intfindColumn(String columnLabel) Map the given column label to its column index.booleanfirst()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.booleangetBoolean(int columnIndex) Retrieve the value of the indicated column in the current row as a boolean.booleangetBoolean(String columnLabel) Retrieve the value of the indicated column in the current row as a boolean.bytegetByte(int columnIndex) Retrieve the value of the indicated column in the current row as a byte.byteRetrieve 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.Retrieve the value of the indicated column in the current row as a Date object.Retrieve the value of the indicated column in the current row as a Date object.Retrieve the value of the indicated column in the current row as a Date object.doublegetDouble(int columnIndex) Retrieve the value of the indicated column in the current row as a Double object.doubleRetrieve the value of the indicated column in the current row as a Double object.floatgetFloat(int columnIndex) Retrieve the value of the indicated column in the current row as a float.floatRetrieve the value of the indicated column in the current row as a float.intgetInt(int columnIndex) Retrieve the value of the indicated column in the current row as an int.intRetrieve the value of the indicated column in the current row as an int.longgetLong(int columnIndex) Retrieve the value of the indicated column in the current row as a long.longRetrieve the value of the indicated column in the current row as a long.final SqlRowSetMetaDataRetrieve 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> TRetrieve the value of the indicated column in the current row as an Object.Retrieve the value of the indicated column in the current row as an Object.Retrieve the value of the indicated column in the current row as an Object.<T> TRetrieve the value of the indicated column in the current row as an Object.Retrieve the value of the indicated column in the current row as an Object.final ResultSetReturn the underlying ResultSet (usually ajavax.sql.rowset.CachedRowSet).intgetRow()Retrieve the current row number.shortgetShort(int columnIndex) Retrieve the value of the indicated column in the current row as a short.shortRetrieve 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.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.Retrieve the value of the indicated column in the current row as a Time object.Retrieve the value of the indicated column in the current row as a Time object.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.booleanRetrieve whether the cursor is after the last row of this row set.booleanRetrieve whether the cursor is before the first row of this row set.booleanisFirst()Retrieve whether the cursor is on the first row of this row set.booleanisLast()Retrieve whether the cursor is on the last row of this row set.booleanlast()Move the cursor to the last row of this row set.booleannext()Move the cursor to the next row.booleanprevious()Move the cursor to the previous row.booleanrelative(int rows) Move the cursor a relative number of rows, either positive or negative.booleanwasNull()Report whether the last column read had a value of SQLNULL.
- 
Constructor Details- 
ResultSetWrappingSqlRowSetCreate a new ResultSetWrappingSqlRowSet for the given ResultSet.- Parameters:
- resultSet- a disconnected ResultSet to wrap (usually a- javax.sql.rowset.CachedRowSet)
- Throws:
- InvalidResultSetAccessException- if extracting the ResultSetMetaData failed
- See Also:
 
 
- 
- 
Method Details- 
getResultSetReturn the underlying ResultSet (usually ajavax.sql.rowset.CachedRowSet).- See Also:
 
- 
getMetaDataDescription copied from interface:SqlRowSetRetrieve the meta-data, i.e. number, types and properties for the columns of this row set.- Specified by:
- getMetaDatain interface- SqlRowSet
- Returns:
- a corresponding SqlRowSetMetaData instance
- See Also:
 
- 
findColumnDescription copied from interface:SqlRowSetMap the given column label to its column index.- Specified by:
- findColumnin interface- SqlRowSet
- Parameters:
- columnLabel- the name of the column
- Returns:
- the column index for the given column label
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getBigDecimalDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a BigDecimal object.- Specified by:
- getBigDecimalin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- an BigDecimal object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getBigDecimal@Nullable public BigDecimal getBigDecimal(String columnLabel) throws InvalidResultSetAccessException Description copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a BigDecimal object.- Specified by:
- getBigDecimalin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- an BigDecimal object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getBooleanDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a boolean.- Specified by:
- getBooleanin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- a boolean representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getBooleanDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a boolean.- Specified by:
- getBooleanin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- a boolean representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getByteDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a byte.- Specified by:
- getBytein interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- a byte representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getByteDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a byte.- Specified by:
- getBytein interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- a byte representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getDateDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Date object.- Specified by:
- getDatein interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- a Date object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getDateDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Date object.- Specified by:
- getDatein interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- a Date object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getDateDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Date object.- Specified by:
- getDatein interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- cal- the Calendar to use in constructing the Date
- Returns:
- a Date object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getDate@Nullable public Date getDate(String columnLabel, Calendar cal) throws InvalidResultSetAccessException Description copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Date object.- Specified by:
- getDatein interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- cal- the Calendar to use in constructing the Date
- Returns:
- a Date object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getDoubleDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Double object.- Specified by:
- getDoublein interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- a Double object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getDoubleDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Double object.- Specified by:
- getDoublein interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- a Double object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getFloatDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a float.- Specified by:
- getFloatin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- a float representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getFloatDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a float.- Specified by:
- getFloatin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- a float representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getIntDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as an int.- Specified by:
- getIntin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- an int representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getIntDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as an int.- Specified by:
- getIntin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- an int representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getLongDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a long.- Specified by:
- getLongin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- a long representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getLongDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a long.- Specified by:
- getLongin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- a long representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getNStringDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a String (for NCHAR, NVARCHAR, LONGNVARCHAR columns).- Specified by:
- getNStringin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- a String representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getNStringDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a String (for NCHAR, NVARCHAR, LONGNVARCHAR columns).- Specified by:
- getNStringin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- a String representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getObjectDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as an Object.- Specified by:
- getObjectin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- a Object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getObjectDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as an Object.- Specified by:
- getObjectin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- a Object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getObject@Nullable public Object getObject(int columnIndex, Map<String, Class<?>> map) throws InvalidResultSetAccessExceptionDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as an Object.- Specified by:
- getObjectin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- map- a Map object containing the mapping from SQL types to Java types
- Returns:
- a Object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getObject@Nullable public Object getObject(String columnLabel, Map<String, Class<?>> map) throws InvalidResultSetAccessExceptionDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as an Object.- Specified by:
- getObjectin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- map- a Map object containing the mapping from SQL types to Java types
- Returns:
- a Object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getObject@Nullable public <T> T getObject(int columnIndex, Class<T> type) throws InvalidResultSetAccessException Description copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as an Object.- Specified by:
- getObjectin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- type- the Java type to convert the designated column to
- Returns:
- a Object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getObject@Nullable public <T> T getObject(String columnLabel, Class<T> type) throws InvalidResultSetAccessException Description copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as an Object.- Specified by:
- getObjectin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- type- the Java type to convert the designated column to
- Returns:
- a Object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getShortDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a short.- Specified by:
- getShortin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- a short representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getShortDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a short.- Specified by:
- getShortin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- a short representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getStringDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a String.- Specified by:
- getStringin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- a String representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getStringDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a String.- Specified by:
- getStringin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- a String representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getTimeDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Time object.- Specified by:
- getTimein interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- a Time object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getTimeDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Time object.- Specified by:
- getTimein interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- a Time object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getTimeDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Time object.- Specified by:
- getTimein interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- cal- the Calendar to use in constructing the Date
- Returns:
- a Time object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getTime@Nullable public Time getTime(String columnLabel, Calendar cal) throws InvalidResultSetAccessException Description copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Time object.- Specified by:
- getTimein interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- cal- the Calendar to use in constructing the Date
- Returns:
- a Time object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getTimestampDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Timestamp object.- Specified by:
- getTimestampin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- Returns:
- a Timestamp object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getTimestampDescription copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Timestamp object.- Specified by:
- getTimestampin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- Returns:
- a Timestamp object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getTimestamp@Nullable public Timestamp getTimestamp(int columnIndex, Calendar cal) throws InvalidResultSetAccessException Description copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Timestamp object.- Specified by:
- getTimestampin interface- SqlRowSet
- Parameters:
- columnIndex- the column index
- cal- the Calendar to use in constructing the Date
- Returns:
- a Timestamp object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getTimestamp@Nullable public Timestamp getTimestamp(String columnLabel, Calendar cal) throws InvalidResultSetAccessException Description copied from interface:SqlRowSetRetrieve the value of the indicated column in the current row as a Timestamp object.- Specified by:
- getTimestampin interface- SqlRowSet
- Parameters:
- columnLabel- the column label
- cal- the Calendar to use in constructing the Date
- Returns:
- a Timestamp object representing the column value
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
absoluteDescription copied from interface:SqlRowSetMove the cursor to the given row number in the row set, just after the last row.- Specified by:
- absolutein interface- SqlRowSet
- Parameters:
- row- the number of the row where the cursor should move
- Returns:
- trueif the cursor is on the row set,- falseotherwise
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
afterLastDescription copied from interface:SqlRowSetMove the cursor to the end of this row set.- Specified by:
- afterLastin interface- SqlRowSet
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
beforeFirstDescription copied from interface:SqlRowSetMove the cursor to the front of this row set, just before the first row.- Specified by:
- beforeFirstin interface- SqlRowSet
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
firstDescription copied from interface:SqlRowSetMove the cursor to the first row of this row set.- Specified by:
- firstin interface- SqlRowSet
- Returns:
- trueif the cursor is on a valid row,- falseotherwise
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
getRowDescription copied from interface:SqlRowSetRetrieve the current row number.- Specified by:
- getRowin interface- SqlRowSet
- Returns:
- the current row number
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
isAfterLastDescription copied from interface:SqlRowSetRetrieve whether the cursor is after the last row of this row set.- Specified by:
- isAfterLastin interface- SqlRowSet
- Returns:
- trueif the cursor is after the last row,- falseotherwise
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
isBeforeFirstDescription copied from interface:SqlRowSetRetrieve whether the cursor is before the first row of this row set.- Specified by:
- isBeforeFirstin interface- SqlRowSet
- Returns:
- trueif the cursor is before the first row,- falseotherwise
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
isFirstDescription copied from interface:SqlRowSetRetrieve whether the cursor is on the first row of this row set.- Specified by:
- isFirstin interface- SqlRowSet
- Returns:
- trueif the cursor is after the first row,- falseotherwise
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
isLastDescription copied from interface:SqlRowSetRetrieve whether the cursor is on the last row of this row set.- Specified by:
- isLastin interface- SqlRowSet
- Returns:
- trueif the cursor is after the last row,- falseotherwise
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
lastDescription copied from interface:SqlRowSetMove the cursor to the last row of this row set.- Specified by:
- lastin interface- SqlRowSet
- Returns:
- trueif the cursor is on a valid row,- falseotherwise
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
nextDescription copied from interface:SqlRowSetMove the cursor to the next row.- Specified by:
- nextin interface- SqlRowSet
- Returns:
- trueif the new row is valid,- falseif there are no more rows
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
previousDescription copied from interface:SqlRowSetMove the cursor to the previous row.- Specified by:
- previousin interface- SqlRowSet
- Returns:
- trueif the new row is valid,- falseif it is off the row set
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
relativeDescription copied from interface:SqlRowSetMove the cursor a relative number of rows, either positive or negative.- Specified by:
- relativein interface- SqlRowSet
- Returns:
- trueif the cursor is on a row,- falseotherwise
- Throws:
- InvalidResultSetAccessException
- See Also:
 
- 
wasNullDescription copied from interface:SqlRowSetReport whether the last column read had a value of SQLNULL.Note that you must first call one of the getter methods and then call the wasNull()method.- Specified by:
- wasNullin interface- SqlRowSet
- Returns:
- trueif the most recent column retrieved was SQL- NULL,- falseotherwise
- Throws:
- InvalidResultSetAccessException
- See Also:
 
 
-