public class

ResultSetWrappingSqlRowSet

extends Object
implements SqlRowSet
java.lang.Object
   ↳ org.springframework.jdbc.support.rowset.ResultSetWrappingSqlRowSet

Class Overview

Default implementation of Spring's SqlRowSet interface.

This implementation wraps a javax.sql.ResultSet, catching any SQLExceptions and translating them to the appropriate Spring InvalidResultSetAccessException.

The passed-in ResultSets 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.

Summary

Public Constructors
ResultSetWrappingSqlRowSet(ResultSet resultSet)
Create a new ResultSetWrappingSqlRowSet for the given ResultSet.
Public Methods
boolean absolute(int row)
Moves the cursor to the given row number in the RowSet, just after the last row.
void afterLast()
Moves the cursor to the end of this RowSet.
void beforeFirst()
Moves the cursor to the front of this RowSet, just before the first row.
int findColumn(String columnLabel)
Maps the given column label to its column index.
boolean first()
Moves the cursor to the first row of this RowSet.
BigDecimal getBigDecimal(int columnIndex)
Retrieves the value of the indicated column in the current row as an BigDecimal object.
BigDecimal getBigDecimal(String columnLabel)
Retrieves the value of the indicated column in the current row as an BigDecimal object.
boolean getBoolean(int columnIndex)
Retrieves the value of the indicated column in the current row as a boolean.
boolean getBoolean(String columnLabel)
Retrieves the value of the indicated column in the current row as a boolean.
byte getByte(String columnLabel)
Retrieves the value of the indicated column in the current row as a byte.
byte getByte(int columnIndex)
Retrieves the value of the indicated column in the current row as a byte.
Date getDate(int columnIndex, Calendar cal)
Retrieves the value of the indicated column in the current row as a Date object.
Date getDate(int columnIndex)
Retrieves the value of the indicated column in the current row as a Date object.
Date getDate(String columnLabel, Calendar cal)
Retrieves the value of the indicated column in the current row as a Date object.
Date getDate(String columnLabel)
Retrieves the value of the indicated column in the current row as a Date object.
double getDouble(String columnLabel)
Retrieves the value of the indicated column in the current row as a Double object.
double getDouble(int columnIndex)
Retrieves the value of the indicated column in the current row as a Double object.
float getFloat(int columnIndex)
Retrieves the value of the indicated column in the current row as a float.
float getFloat(String columnLabel)
Retrieves the value of the indicated column in the current row as a float.
int getInt(String columnLabel)
Retrieves the value of the indicated column in the current row as an int.
int getInt(int columnIndex)
Retrieves the value of the indicated column in the current row as an int.
long getLong(String columnLabel)
Retrieves the value of the indicated column in the current row as a long.
long getLong(int columnIndex)
Retrieves the value of the indicated column in the current row as a long.
final SqlRowSetMetaData getMetaData()
Retrieves the meta data (number, types and properties for the columns) of this row set.
Object getObject(int i, Map<StringClass<?>> map)
Retrieves the value of the indicated column in the current row as an Object.
Object getObject(String columnLabel)
Retrieves the value of the indicated column in the current row as an Object.
Object getObject(String columnLabel, Map<StringClass<?>> map)
Retrieves the value of the indicated column in the current row as an Object.
Object getObject(int columnIndex)
Retrieves the value of the indicated column in the current row as an Object.
final ResultSet getResultSet()
Return the underlying ResultSet (usually a javax.sql.rowset.CachedRowSet).
int getRow()
Retrieves the current row number.
short getShort(int columnIndex)
Retrieves the value of the indicated column in the current row as a short.
short getShort(String columnLabel)
Retrieves the value of the indicated column in the current row as a short.
String getString(int columnIndex)
Retrieves the value of the indicated column in the current row as a String.
String getString(String columnLabel)
Retrieves the value of the indicated column in the current row as a String.
Time getTime(String columnLabel)
Retrieves the value of the indicated column in the current row as a Time object.
Time getTime(int columnIndex, Calendar cal)
Retrieves the value of the indicated column in the current row as a Time object.
Time getTime(int columnIndex)
Retrieves the value of the indicated column in the current row as a Time object.
Time getTime(String columnLabel, Calendar cal)
Retrieves the value of the indicated column in the current row as a Time object.
Timestamp getTimestamp(String columnLabel)
Retrieves the value of the indicated column in the current row as a Timestamp object.
Timestamp getTimestamp(String columnLabel, Calendar cal)
Retrieves the value of the indicated column in the current row as a Timestamp object.
Timestamp getTimestamp(int columnIndex, Calendar cal)
Retrieves the value of the indicated column in the current row as a Timestamp object.
Timestamp getTimestamp(int columnIndex)
Retrieves the value of the indicated column in the current row as a Timestamp object.
boolean isAfterLast()
Retrieves whether the cursor is after the last row of this RowSet.
boolean isBeforeFirst()
Retrieves whether the cursor is after the first row of this RowSet.
boolean isFirst()
Retrieves whether the cursor is on the first row of this RowSet.
boolean isLast()
Retrieves whether the cursor is on the last row of this RowSet.
boolean last()
Moves the cursor to the last row of this RowSet.
boolean next()
Moves the cursor to the next row.
boolean previous()
Moves the cursor to the previous row.
boolean relative(int rows)
Moves the cursor a relative number f rows, either positive or negative.
boolean wasNull()
Reports whether the last column read had a value of SQL NULL.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.jdbc.support.rowset.SqlRowSet

Public Constructors

public ResultSetWrappingSqlRowSet (ResultSet resultSet)

Create 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

Public Methods

public boolean absolute (int row)

Moves the cursor to the given row number in the RowSet, just after the last row.

Parameters
row the number of the row where the cursor should move
Returns
  • true if the cursor is on the RowSet, false otherwise
See Also

public void afterLast ()

Moves the cursor to the end of this RowSet.

See Also

public void beforeFirst ()

Moves the cursor to the front of this RowSet, just before the first row.

See Also

public int findColumn (String columnLabel)

Maps the given column label to its column index.

Parameters
columnLabel the name of the column
Returns
  • the column index for the given column label

public boolean first ()

Moves the cursor to the first row of this RowSet.

Returns
  • true if the cursor is on a valid row, false otherwise
See Also

public BigDecimal getBigDecimal (int columnIndex)

Retrieves the value of the indicated column in the current row as an BigDecimal object.

Parameters
columnIndex the column index
Returns
  • an BigDecimal object representing the column value

public BigDecimal getBigDecimal (String columnLabel)

Retrieves the value of the indicated column in the current row as an BigDecimal object.

Parameters
columnLabel the column label
Returns
  • an BigDecimal object representing the column value

public boolean getBoolean (int columnIndex)

Retrieves the value of the indicated column in the current row as a boolean.

Parameters
columnIndex the column index
Returns
  • a boolean representing the column value
See Also

public boolean getBoolean (String columnLabel)

Retrieves the value of the indicated column in the current row as a boolean.

Parameters
columnLabel the column label
Returns
  • a boolean representing the column value

public byte getByte (String columnLabel)

Retrieves the value of the indicated column in the current row as a byte.

Parameters
columnLabel the column label
Returns
  • a byte representing the column value
See Also

public byte getByte (int columnIndex)

Retrieves the value of the indicated column in the current row as a byte.

Parameters
columnIndex the column index
Returns
  • a byte representing the column value
See Also

public Date getDate (int columnIndex, Calendar cal)

Retrieves the value of the indicated column in the current row as a Date object.

Parameters
columnIndex the column index
cal the Calendar to use in constructing the Date
Returns
  • a Date object representing the column value

public Date getDate (int columnIndex)

Retrieves the value of the indicated column in the current row as a Date object.

Parameters
columnIndex the column index
Returns
  • a Date object representing the column value
See Also

public Date getDate (String columnLabel, Calendar cal)

Retrieves the value of the indicated column in the current row as a Date object.

Parameters
columnLabel the column label
cal the Calendar to use in constructing the Date
Returns
  • a Date object representing the column value

public Date getDate (String columnLabel)

Retrieves the value of the indicated column in the current row as a Date object.

Parameters
columnLabel the column label
Returns
  • a Date object representing the column value
See Also

public double getDouble (String columnLabel)

Retrieves the value of the indicated column in the current row as a Double object.

Parameters
columnLabel the column label
Returns
  • a Double object representing the column value

public double getDouble (int columnIndex)

Retrieves the value of the indicated column in the current row as a Double object.

Parameters
columnIndex the column index
Returns
  • a Double object representing the column value
See Also

public float getFloat (int columnIndex)

Retrieves the value of the indicated column in the current row as a float.

Parameters
columnIndex the column index
Returns
  • a float representing the column value
See Also

public float getFloat (String columnLabel)

Retrieves the value of the indicated column in the current row as a float.

Parameters
columnLabel the column label
Returns
  • a float representing the column value
See Also

public int getInt (String columnLabel)

Retrieves the value of the indicated column in the current row as an int.

Parameters
columnLabel the column label
Returns
  • an int representing the column value
See Also

public int getInt (int columnIndex)

Retrieves the value of the indicated column in the current row as an int.

Parameters
columnIndex the column index
Returns
  • an int representing the column value
See Also

public long getLong (String columnLabel)

Retrieves the value of the indicated column in the current row as a long.

Parameters
columnLabel the column label
Returns
  • a long representing the column value
See Also

public long getLong (int columnIndex)

Retrieves the value of the indicated column in the current row as a long.

Parameters
columnIndex the column index
Returns
  • a long representing the column value
See Also

public final SqlRowSetMetaData getMetaData ()

Retrieves the meta data (number, types and properties for the columns) of this row set.

Returns
  • a corresponding SqlRowSetMetaData instance

public Object getObject (int i, Map<StringClass<?>> map)

Retrieves the value of the indicated column in the current row as an Object.

Parameters
i the column index
map a Map object containing the mapping from SQL types to Java types
Returns
  • a Object representing the column value

public Object getObject (String columnLabel)

Retrieves the value of the indicated column in the current row as an Object.

Parameters
columnLabel the column label
Returns
  • a Object representing the column value

public Object getObject (String columnLabel, Map<StringClass<?>> map)

Retrieves the value of the indicated column in the current row as an Object.

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

public Object getObject (int columnIndex)

Retrieves the value of the indicated column in the current row as an Object.

Parameters
columnIndex the column index
Returns
  • a Object representing the column value
See Also

public final ResultSet getResultSet ()

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

See Also

public int getRow ()

Retrieves the current row number.

Returns
  • the current row number
See Also

public short getShort (int columnIndex)

Retrieves the value of the indicated column in the current row as a short.

Parameters
columnIndex the column index
Returns
  • a short representing the column value
See Also

public short getShort (String columnLabel)

Retrieves the value of the indicated column in the current row as a short.

Parameters
columnLabel the column label
Returns
  • a short representing the column value
See Also

public String getString (int columnIndex)

Retrieves the value of the indicated column in the current row as a String.

Parameters
columnIndex the column index
Returns
  • a String representing the column value
See Also

public String getString (String columnLabel)

Retrieves the value of the indicated column in the current row as a String.

Parameters
columnLabel the column label
Returns
  • a String representing the column value

public Time getTime (String columnLabel)

Retrieves the value of the indicated column in the current row as a Time object.

Parameters
columnLabel the column label
Returns
  • a Time object representing the column value
See Also

public Time getTime (int columnIndex, Calendar cal)

Retrieves the value of the indicated column in the current row as a Time object.

Parameters
columnIndex the column index
cal the Calendar to use in constructing the Date
Returns
  • a Time object representing the column value

public Time getTime (int columnIndex)

Retrieves the value of the indicated column in the current row as a Time object.

Parameters
columnIndex the column index
Returns
  • a Time object representing the column value
See Also

public Time getTime (String columnLabel, Calendar cal)

Retrieves the value of the indicated column in the current row as a Time object.

Parameters
columnLabel the column label
cal the Calendar to use in constructing the Date
Returns
  • a Time object representing the column value

public Timestamp getTimestamp (String columnLabel)

Retrieves the value of the indicated column in the current row as a Timestamp object.

Parameters
columnLabel the column label
Returns
  • a Timestamp object representing the column value

public Timestamp getTimestamp (String columnLabel, Calendar cal)

Retrieves the value of the indicated column in the current row as a Timestamp object.

Parameters
columnLabel the column label
cal the Calendar to use in constructing the Date
Returns
  • a Timestamp object representing the column value

public Timestamp getTimestamp (int columnIndex, Calendar cal)

Retrieves the value of the indicated column in the current row as a Timestamp object.

Parameters
columnIndex the column index
cal the Calendar to use in constructing the Date
Returns
  • a Timestamp object representing the column value

public Timestamp getTimestamp (int columnIndex)

Retrieves the value of the indicated column in the current row as a Timestamp object.

Parameters
columnIndex the column index
Returns
  • a Timestamp object representing the column value

public boolean isAfterLast ()

Retrieves whether the cursor is after the last row of this RowSet.

Returns
  • true if the cursor is after the last row, false otherwise
See Also

public boolean isBeforeFirst ()

Retrieves whether the cursor is after the first row of this RowSet.

Returns
  • true if the cursor is after the first row, false otherwise
See Also

public boolean isFirst ()

Retrieves whether the cursor is on the first row of this RowSet.

Returns
  • true if the cursor is after the first row, false otherwise
See Also

public boolean isLast ()

Retrieves whether the cursor is on the last row of this RowSet.

Returns
  • true if the cursor is after the last row, false otherwise
See Also

public boolean last ()

Moves the cursor to the last row of this RowSet.

Returns
  • true if the cursor is on a valid row, false otherwise
See Also

public boolean next ()

Moves the cursor to the next row.

Returns
  • true if the new row is valid, false if there are no more rows
See Also

public boolean previous ()

Moves the cursor to the previous row.

Returns
  • true if the new row is valid, false if it is off the RowSet
See Also

public boolean relative (int rows)

Moves the cursor a relative number f rows, either positive or negative.

Returns
  • true if the cursor is on a row, false otherwise
See Also

public boolean wasNull ()

Reports whether the last column read had a value of SQL NULL. Note that you must first call one of the getter methods and then call the wasNull method.

Returns
  • true if the most recent coumn retrieved was SQL NULL, false otherwise
See Also