|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.jdbc.support.rowset.ResultSetWrappingSqlRowSet
public class ResultSetWrappingSqlRowSet
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.
ResultSet,
CachedRowSet,
JdbcTemplate.queryForRowSet(java.lang.String),
Serialized Form| Constructor Summary | |
|---|---|
ResultSetWrappingSqlRowSet(ResultSet resultSet)
Create a new ResultSetWrappingSqlRowSet for the given ResultSet. |
|
| Method Summary | |
|---|---|
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(int columnIndex)
Retrieves the value of the indicated column in the current row as a byte. |
byte |
getByte(String columnLabel)
Retrieves the value of the indicated column in the current row as a byte. |
Date |
getDate(int columnIndex)
Retrieves the value of the indicated column in the current row as a Date object. |
Date |
getDate(int columnIndex,
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. |
Date |
getDate(String columnLabel,
Calendar cal)
Retrieves the value of the indicated column in the current row as a Date object. |
double |
getDouble(int columnIndex)
Retrieves the value of the indicated column in the current row as a Double object. |
double |
getDouble(String columnLabel)
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(int columnIndex)
Retrieves the value of the indicated column in the current row as an int. |
int |
getInt(String columnLabel)
Retrieves the value of the indicated column in the current row as an int. |
long |
getLong(int columnIndex)
Retrieves the value of the indicated column in the current row as a long. |
long |
getLong(String columnLabel)
Retrieves the value of the indicated column in the current row as a long. |
SqlRowSetMetaData |
getMetaData()
Retrieves the meta data (number, types and properties for the columns) of this row set. |
Object |
getObject(int columnIndex)
Retrieves the value of the indicated column in the current row as an Object. |
Object |
getObject(int i,
Map<String,Class<?>> 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<String,Class<?>> map)
Retrieves the value of the indicated column in the current row as an Object. |
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(int columnIndex)
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(String columnLabel)
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(int columnIndex)
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(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. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ResultSetWrappingSqlRowSet(ResultSet resultSet)
throws InvalidResultSetAccessException
resultSet - a disconnected ResultSet to wrap
(usually a javax.sql.rowset.CachedRowSet)
InvalidResultSetAccessException - if extracting
the ResultSetMetaData failedCachedRowSet,
ResultSet.getMetaData(),
ResultSetWrappingSqlRowSetMetaData| Method Detail |
|---|
public final ResultSet getResultSet()
javax.sql.rowset.CachedRowSet).
CachedRowSetpublic final SqlRowSetMetaData getMetaData()
SqlRowSet
getMetaData in interface SqlRowSetResultSetMetaData.getCatalogName(int)
public int findColumn(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
findColumn in interface SqlRowSetcolumnLabel - the name of the column
InvalidResultSetAccessExceptionResultSet.findColumn(String)
public BigDecimal getBigDecimal(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getBigDecimal in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getBigDecimal(int)
public BigDecimal getBigDecimal(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getBigDecimal in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getBigDecimal(String)
public boolean getBoolean(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getBoolean in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getBoolean(int)
public boolean getBoolean(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getBoolean in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getBoolean(String)
public byte getByte(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getByte in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getByte(int)
public byte getByte(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getByte in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getByte(String)
public Date getDate(int columnIndex,
Calendar cal)
throws InvalidResultSetAccessException
SqlRowSet
getDate in interface SqlRowSetcolumnIndex - the column indexcal - the Calendar to use in constructing the Date
InvalidResultSetAccessExceptionResultSet.getDate(int, java.util.Calendar)
public Date getDate(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getDate in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getDate(int)
public Date getDate(String columnLabel,
Calendar cal)
throws InvalidResultSetAccessException
SqlRowSet
getDate in interface SqlRowSetcolumnLabel - the column labelcal - the Calendar to use in constructing the Date
InvalidResultSetAccessExceptionResultSet.getDate(String, java.util.Calendar)
public Date getDate(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getDate in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getDate(String)
public double getDouble(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getDouble in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getDouble(int)
public double getDouble(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getDouble in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getDouble(String)
public float getFloat(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getFloat in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getFloat(int)
public float getFloat(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getFloat in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getFloat(String)
public int getInt(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getInt in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getInt(int)
public int getInt(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getInt in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getInt(String)
public long getLong(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getLong in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getLong(int)
public long getLong(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getLong in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getLong(String)
public Object getObject(int i,
Map<String,Class<?>> map)
throws InvalidResultSetAccessException
SqlRowSet
getObject in interface SqlRowSeti - the column indexmap - a Map object containing the mapping from SQL types to Java types
InvalidResultSetAccessExceptionResultSet.getObject(int, java.util.Map)
public Object getObject(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getObject in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getObject(int)
public Object getObject(String columnLabel,
Map<String,Class<?>> map)
throws InvalidResultSetAccessException
SqlRowSet
getObject in interface SqlRowSetcolumnLabel - the column labelmap - a Map object containing the mapping from SQL types to Java types
InvalidResultSetAccessExceptionResultSet.getObject(String, java.util.Map)
public Object getObject(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getObject in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getObject(String)
public short getShort(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getShort in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getShort(int)
public short getShort(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getShort in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getShort(String)
public String getString(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getString in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getString(int)
public String getString(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getString in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getString(String)
public Time getTime(int columnIndex,
Calendar cal)
throws InvalidResultSetAccessException
SqlRowSet
getTime in interface SqlRowSetcolumnIndex - the column indexcal - the Calendar to use in constructing the Date
InvalidResultSetAccessExceptionResultSet.getTime(int, java.util.Calendar)
public Time getTime(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getTime in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getTime(int)
public Time getTime(String columnLabel,
Calendar cal)
throws InvalidResultSetAccessException
SqlRowSet
getTime in interface SqlRowSetcolumnLabel - the column labelcal - the Calendar to use in constructing the Date
InvalidResultSetAccessExceptionResultSet.getTime(String, java.util.Calendar)
public Time getTime(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getTime in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getTime(String)
public Timestamp getTimestamp(int columnIndex,
Calendar cal)
throws InvalidResultSetAccessException
SqlRowSet
getTimestamp in interface SqlRowSetcolumnIndex - the column indexcal - the Calendar to use in constructing the Date
InvalidResultSetAccessExceptionResultSet.getTimestamp(int, java.util.Calendar)
public Timestamp getTimestamp(int columnIndex)
throws InvalidResultSetAccessException
SqlRowSet
getTimestamp in interface SqlRowSetcolumnIndex - the column index
InvalidResultSetAccessExceptionResultSet.getTimestamp(int)
public Timestamp getTimestamp(String columnLabel,
Calendar cal)
throws InvalidResultSetAccessException
SqlRowSet
getTimestamp in interface SqlRowSetcolumnLabel - the column labelcal - the Calendar to use in constructing the Date
InvalidResultSetAccessExceptionResultSet.getTimestamp(String, java.util.Calendar)
public Timestamp getTimestamp(String columnLabel)
throws InvalidResultSetAccessException
SqlRowSet
getTimestamp in interface SqlRowSetcolumnLabel - the column label
InvalidResultSetAccessExceptionResultSet.getTimestamp(String)
public boolean absolute(int row)
throws InvalidResultSetAccessException
SqlRowSet
absolute in interface SqlRowSetrow - the number of the row where the cursor should move
InvalidResultSetAccessExceptionResultSet.absolute(int)
public void afterLast()
throws InvalidResultSetAccessException
SqlRowSet
afterLast in interface SqlRowSetInvalidResultSetAccessExceptionResultSet.afterLast()
public void beforeFirst()
throws InvalidResultSetAccessException
SqlRowSet
beforeFirst in interface SqlRowSetInvalidResultSetAccessExceptionResultSet.beforeFirst()
public boolean first()
throws InvalidResultSetAccessException
SqlRowSet
first in interface SqlRowSetInvalidResultSetAccessExceptionResultSet.first()
public int getRow()
throws InvalidResultSetAccessException
SqlRowSet
getRow in interface SqlRowSetInvalidResultSetAccessExceptionResultSet.getRow()
public boolean isAfterLast()
throws InvalidResultSetAccessException
SqlRowSet
isAfterLast in interface SqlRowSetInvalidResultSetAccessExceptionResultSet.isAfterLast()
public boolean isBeforeFirst()
throws InvalidResultSetAccessException
SqlRowSet
isBeforeFirst in interface SqlRowSetInvalidResultSetAccessExceptionResultSet.isBeforeFirst()
public boolean isFirst()
throws InvalidResultSetAccessException
SqlRowSet
isFirst in interface SqlRowSetInvalidResultSetAccessExceptionResultSet.isFirst()
public boolean isLast()
throws InvalidResultSetAccessException
SqlRowSet
isLast in interface SqlRowSetInvalidResultSetAccessExceptionResultSet.isLast()
public boolean last()
throws InvalidResultSetAccessException
SqlRowSet
last in interface SqlRowSetInvalidResultSetAccessExceptionResultSet.last()
public boolean next()
throws InvalidResultSetAccessException
SqlRowSet
next in interface SqlRowSetInvalidResultSetAccessExceptionResultSet.next()
public boolean previous()
throws InvalidResultSetAccessException
SqlRowSet
previous in interface SqlRowSetInvalidResultSetAccessExceptionResultSet.previous()
public boolean relative(int rows)
throws InvalidResultSetAccessException
SqlRowSet
relative in interface SqlRowSetInvalidResultSetAccessExceptionResultSet.relative(int)
public boolean wasNull()
throws InvalidResultSetAccessException
SqlRowSetNULL.
Note that you must first call one of the getter methods and then call
the wasNull method.
wasNull in interface SqlRowSetNULL,
false otherwise
InvalidResultSetAccessExceptionResultSet.wasNull()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||