This class is a simple result set and meta data implementation.
It can be used in Java functions that return a result set.
Only the most basic methods are implemented, the others throw an exception.
This implementation is standalone, and only relies on standard classes.
It can be extended easily if required.
An application can create a result set using the following code:
Methods |
|
SimpleResultSet()
This constructor is used if the result set is later populated with
addRow.
|
|
SimpleResultSet()
This constructor is used if the result set is later populated with
addRow.
|
|
SimpleResultSet(SimpleRowSource source)
This constructor is used if the result set should retrieve the rows using
the specified row source object.
|
|
SimpleResultSet(SimpleRowSource source)
This constructor is used if the result set should retrieve the rows using
the specified row source object.
Parameters:
source - the row source
|
void |
addColumn(String name, int sqlType, int precision, int scale)
Adds a column to the result set.
|
void |
addColumn(String name, int sqlType, int precision, int scale)
Adds a column to the result set.
All columns must be added before adding rows.
This method uses the default SQL type names.
Parameters:
name - null is replaced with C1, C2,...
sqlType - the value returned in getColumnType(..)
precision - the precision
scale - the scale
|
void |
addColumn(String name, int sqlType, String sqlTypeName, int precision, int scale)
Adds a column to the result set.
|
void |
addColumn(String name, int sqlType, String sqlTypeName, int precision, int scale)
Adds a column to the result set.
All columns must be added before adding rows.
Parameters:
name - null is replaced with C1, C2,...
sqlType - the value returned in getColumnType(..)
sqlTypeName - the type name return in getColumnTypeName(..)
precision - the precision
scale - the scale
|
void |
addRow(Object... row)
Add a new row to the result set.
|
void |
addRow(Object... row)
Add a new row to the result set.
Do not use this method when using a RowSource.
Parameters:
row - the row as an array of objects
|
void |
beforeFirst()
Moves the current position to before the first row, that means the result
set is reset.
|
void |
beforeFirst() throws SQLException
Moves the current position to before the first row, that means the result
set is reset.
|
void |
close()
Closes the result set and releases the resources.
|
void |
close()
Closes the result set and releases the resources.
|
int |
findColumn(String columnLabel)
Searches for a specific column in the result set.
|
int |
findColumn(String columnLabel) throws SQLException
Searches for a specific column in the result set. A case-insensitive
search is made.
Parameters:
columnLabel - the column label
Returns:
the column index (1,2,...)
Throws:
SQLException - if the column is not found or if the result set is
closed
|
Array |
getArray(int columnIndex)
Returns the value as a java.sql.Array.
|
Array |
getArray(int columnIndex) throws SQLException
Returns the value as a java.sql.Array.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
Array |
getArray(String columnLabel)
Returns the value as a java.sql.Array.
|
Array |
getArray(String columnLabel) throws SQLException
Returns the value as a java.sql.Array.
Parameters:
columnLabel - the column label
Returns:
the value
|
boolean |
getAutoClose()
Get the current auto-close behavior.
|
boolean |
getAutoClose()
Get the current auto-close behavior.
Returns:
the auto-close value
|
BigDecimal |
getBigDecimal(int columnIndex)
Returns the value as a java.math.BigDecimal.
|
BigDecimal |
getBigDecimal(int columnIndex) throws SQLException
Returns the value as a java.math.BigDecimal.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
BigDecimal |
getBigDecimal(String columnLabel)
Returns the value as a java.math.BigDecimal.
|
BigDecimal |
getBigDecimal(String columnLabel) throws SQLException
Returns the value as a java.math.BigDecimal.
Parameters:
columnLabel - the column label
Returns:
the value
|
InputStream |
getBinaryStream(int columnIndex)
Returns the value as a java.io.InputStream.
|
InputStream |
getBinaryStream(int columnIndex) throws SQLException
Returns the value as a java.io.InputStream.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
InputStream |
getBinaryStream(String columnLabel)
Returns the value as a java.io.InputStream.
|
InputStream |
getBinaryStream(String columnLabel) throws SQLException
Returns the value as a java.io.InputStream.
Parameters:
columnLabel - the column label
Returns:
the value
|
Blob |
getBlob(int columnIndex)
Returns the value as a java.sql.Blob.
|
Blob |
getBlob(int columnIndex) throws SQLException
Returns the value as a java.sql.Blob.
This is only supported if the
result set was created using a Blob object.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
Blob |
getBlob(String columnLabel)
Returns the value as a java.sql.Blob.
|
Blob |
getBlob(String columnLabel) throws SQLException
Returns the value as a java.sql.Blob.
This is only supported if the
result set was created using a Blob object.
Parameters:
columnLabel - the column label
Returns:
the value
|
boolean |
getBoolean(int columnIndex)
Returns the value as a boolean.
|
boolean |
getBoolean(int columnIndex) throws SQLException
Returns the value as a boolean.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
boolean |
getBoolean(String columnLabel)
Returns the value as a boolean.
|
boolean |
getBoolean(String columnLabel) throws SQLException
Returns the value as a boolean.
Parameters:
columnLabel - the column label
Returns:
the value
|
byte |
getByte(int columnIndex)
Returns the value as a byte.
|
byte |
getByte(int columnIndex) throws SQLException
Returns the value as a byte.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
byte |
getByte(String columnLabel)
Returns the value as a byte.
|
byte |
getByte(String columnLabel) throws SQLException
Returns the value as a byte.
Parameters:
columnLabel - the column label
Returns:
the value
|
byte[] |
getBytes(int columnIndex)
Returns the value as a byte array.
|
byte[] |
getBytes(int columnIndex) throws SQLException
Returns the value as a byte array.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
byte[] |
getBytes(String columnLabel)
Returns the value as a byte array.
|
byte[] |
getBytes(String columnLabel) throws SQLException
Returns the value as a byte array.
Parameters:
columnLabel - the column label
Returns:
the value
|
String |
getCatalogName(int columnIndex)
Returns null.
|
String |
getCatalogName(int columnIndex)
Returns null.
Parameters:
columnIndex - (1,2,...)
Returns:
null
|
Reader |
getCharacterStream(int columnIndex)
Returns the value as a java.io.Reader.
|
Reader |
getCharacterStream(int columnIndex) throws SQLException
Returns the value as a java.io.Reader.
This is only supported if the
result set was created using a Clob or Reader object.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
Reader |
getCharacterStream(String columnLabel)
Returns the value as a java.io.Reader.
|
Reader |
getCharacterStream(String columnLabel) throws SQLException
Returns the value as a java.io.Reader.
This is only supported if the
result set was created using a Clob or Reader object.
Parameters:
columnLabel - the column label
Returns:
the value
|
Clob |
getClob(int columnIndex)
Returns the value as a java.sql.Clob.
|
Clob |
getClob(int columnIndex) throws SQLException
Returns the value as a java.sql.Clob.
This is only supported if the
result set was created using a Clob object.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
Clob |
getClob(String columnLabel)
Returns the value as a java.sql.Clob.
|
Clob |
getClob(String columnLabel) throws SQLException
Returns the value as a java.sql.Clob.
This is only supported if the
result set was created using a Clob object.
Parameters:
columnLabel - the column label
Returns:
the value
|
String |
getColumnClassName(int columnIndex)
Returns the Java class name if this column.
|
String |
getColumnClassName(int columnIndex) throws SQLException
Returns the Java class name if this column.
Parameters:
columnIndex - (1,2,...)
Returns:
the class name
|
int |
getColumnCount()
Returns the column count.
|
int |
getColumnCount()
Returns the column count.
Returns:
the column count
|
int |
getColumnDisplaySize(int columnIndex)
Returns 15.
|
int |
getColumnDisplaySize(int columnIndex)
Returns 15.
Parameters:
columnIndex - (1,2,...)
Returns:
15
|
String |
getColumnLabel(int columnIndex)
Returns the column label.
|
String |
getColumnLabel(int columnIndex) throws SQLException
Returns the column label.
Parameters:
columnIndex - (1,2,...)
Returns:
the column label
|
String |
getColumnName(int columnIndex)
Returns the column name.
|
String |
getColumnName(int columnIndex) throws SQLException
Returns the column name.
Parameters:
columnIndex - (1,2,...)
Returns:
the column name
|
int |
getColumnType(int columnIndex)
Returns the SQL type.
|
int |
getColumnType(int columnIndex) throws SQLException
Returns the SQL type.
Parameters:
columnIndex - (1,2,...)
Returns:
the SQL type
|
String |
getColumnTypeName(int columnIndex)
Returns the data type name of a column.
|
String |
getColumnTypeName(int columnIndex) throws SQLException
Returns the data type name of a column.
Parameters:
columnIndex - (1,2,...)
Returns:
the type name
|
int |
getConcurrency()
Returns ResultSet.CONCUR_READ_ONLY.
|
int |
getConcurrency()
Returns ResultSet.CONCUR_READ_ONLY.
Returns:
CONCUR_READ_ONLY
|
Date |
getDate(int columnIndex)
Returns the value as an java.sql.Date.
|
Date |
getDate(int columnIndex) throws SQLException
Returns the value as an java.sql.Date.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
Date |
getDate(String columnLabel)
Returns the value as a java.sql.Date.
|
Date |
getDate(String columnLabel) throws SQLException
Returns the value as a java.sql.Date.
Parameters:
columnLabel - the column label
Returns:
the value
|
double |
getDouble(int columnIndex)
Returns the value as an double.
|
double |
getDouble(int columnIndex) throws SQLException
Returns the value as an double.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
double |
getDouble(String columnLabel)
Returns the value as a double.
|
double |
getDouble(String columnLabel) throws SQLException
Returns the value as a double.
Parameters:
columnLabel - the column label
Returns:
the value
|
int |
getFetchDirection()
Returns ResultSet.FETCH_FORWARD.
|
int |
getFetchDirection()
Returns ResultSet.FETCH_FORWARD.
Returns:
FETCH_FORWARD
|
int |
getFetchSize()
Returns 0.
|
int |
getFetchSize()
Returns 0.
Returns:
0
|
float |
getFloat(int columnIndex)
Returns the value as a float.
|
float |
getFloat(int columnIndex) throws SQLException
Returns the value as a float.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
float |
getFloat(String columnLabel)
Returns the value as a float.
|
float |
getFloat(String columnLabel) throws SQLException
Returns the value as a float.
Parameters:
columnLabel - the column label
Returns:
the value
|
int |
getHoldability()
Returns the current result set holdability.
|
int |
getHoldability()
Returns the current result set holdability.
Returns:
the holdability
|
int |
getInt(int columnIndex)
Returns the value as an int.
|
int |
getInt(int columnIndex) throws SQLException
Returns the value as an int.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
int |
getInt(String columnLabel)
Returns the value as an int.
|
int |
getInt(String columnLabel) throws SQLException
Returns the value as an int.
Parameters:
columnLabel - the column label
Returns:
the value
|
long |
getLong(int columnIndex)
Returns the value as a long.
|
long |
getLong(int columnIndex) throws SQLException
Returns the value as a long.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
long |
getLong(String columnLabel)
Returns the value as a long.
|
long |
getLong(String columnLabel) throws SQLException
Returns the value as a long.
Parameters:
columnLabel - the column label
Returns:
the value
|
ResultSetMetaData |
getMetaData()
Returns a reference to itself.
|
ResultSetMetaData |
getMetaData()
Returns a reference to itself.
Returns:
this
|
Object |
getObject(int columnIndex)
Returns the value as an Object.
|
Object |
getObject(int columnIndex) throws SQLException
Returns the value as an Object.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
Object |
getObject(String columnLabel)
Returns the value as an Object.
|
Object |
getObject(String columnLabel) throws SQLException
Returns the value as an Object.
Parameters:
columnLabel - the column label
Returns:
the value
|
int |
getPrecision(int columnIndex)
Returns the precision.
|
int |
getPrecision(int columnIndex) throws SQLException
Returns the precision.
Parameters:
columnIndex - (1,2,...)
Returns:
the precision
|
int |
getRow()
Returns the row number (1, 2,...) or 0 for no row.
|
int |
getRow()
Returns the row number (1, 2,...) or 0 for no row.
Returns:
0
|
int |
getScale(int columnIndex)
Returns the scale.
|
int |
getScale(int columnIndex) throws SQLException
Returns the scale.
Parameters:
columnIndex - (1,2,...)
Returns:
the scale
|
String |
getSchemaName(int columnIndex)
Returns null.
|
String |
getSchemaName(int columnIndex)
Returns null.
Parameters:
columnIndex - (1,2,...)
Returns:
null
|
short |
getShort(int columnIndex)
Returns the value as a short.
|
short |
getShort(int columnIndex) throws SQLException
Returns the value as a short.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
short |
getShort(String columnLabel)
Returns the value as a short.
|
short |
getShort(String columnLabel) throws SQLException
Returns the value as a short.
Parameters:
columnLabel - the column label
Returns:
the value
|
Statement |
getStatement()
Returns null.
|
Statement |
getStatement()
Returns null.
Returns:
null
|
String |
getString(int columnIndex)
Returns the value as a String.
|
String |
getString(int columnIndex) throws SQLException
Returns the value as a String.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
String |
getString(String columnLabel)
Returns the value as a String.
|
String |
getString(String columnLabel) throws SQLException
Returns the value as a String.
Parameters:
columnLabel - the column label
Returns:
the value
|
String |
getTableName(int columnIndex)
Returns null.
|
String |
getTableName(int columnIndex)
Returns null.
Parameters:
columnIndex - (1,2,...)
Returns:
null
|
Time |
getTime(int columnIndex)
Returns the value as an java.sql.Time.
|
Time |
getTime(int columnIndex) throws SQLException
Returns the value as an java.sql.Time.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
Time |
getTime(String columnLabel)
Returns the value as a java.sql.Time.
|
Time |
getTime(String columnLabel) throws SQLException
Returns the value as a java.sql.Time.
Parameters:
columnLabel - the column label
Returns:
the value
|
Timestamp |
getTimestamp(int columnIndex)
Returns the value as an java.sql.Timestamp.
|
Timestamp |
getTimestamp(int columnIndex) throws SQLException
Returns the value as an java.sql.Timestamp.
Parameters:
columnIndex - (1,2,...)
Returns:
the value
|
Timestamp |
getTimestamp(String columnLabel)
Returns the value as a java.sql.Timestamp.
|
Timestamp |
getTimestamp(String columnLabel) throws SQLException
Returns the value as a java.sql.Timestamp.
Parameters:
columnLabel - the column label
Returns:
the value
|
int |
getType()
Returns the result set type.
|
int |
getType()
Returns the result set type. This is ResultSet.TYPE_FORWARD_ONLY for
auto-close result sets, and ResultSet.TYPE_SCROLL_INSENSITIVE for others.
Returns:
TYPE_FORWARD_ONLY or TYPE_SCROLL_INSENSITIVE
|
SQLWarning |
getWarnings()
Returns null.
|
SQLWarning |
getWarnings()
Returns null.
Returns:
null
|
boolean |
isAutoIncrement(int columnIndex)
Returns false.
|
boolean |
isAutoIncrement(int columnIndex)
Returns false.
Parameters:
columnIndex - (1,2,...)
Returns:
false
|
boolean |
isCaseSensitive(int columnIndex)
Returns true.
|
boolean |
isCaseSensitive(int columnIndex)
Returns true.
Parameters:
columnIndex - (1,2,...)
Returns:
true
|
boolean |
isClosed()
Returns whether this result set has been closed.
|
boolean |
isClosed()
Returns whether this result set has been closed.
Returns:
true if the result set was closed
|
boolean |
isCurrency(int columnIndex)
Returns false.
|
boolean |
isCurrency(int columnIndex)
Returns false.
Parameters:
columnIndex - (1,2,...)
Returns:
false
|
boolean |
isDefinitelyWritable(int columnIndex)
Returns false.
|
boolean |
isDefinitelyWritable(int columnIndex)
Returns false.
Parameters:
columnIndex - (1,2,...)
Returns:
false
|
int |
isNullable(int columnIndex)
Returns ResultSetMetaData.columnNullableUnknown.
|
int |
isNullable(int columnIndex)
Returns ResultSetMetaData.columnNullableUnknown.
Parameters:
columnIndex - (1,2,...)
Returns:
columnNullableUnknown
|
boolean |
isReadOnly(int columnIndex)
Returns true.
|
boolean |
isReadOnly(int columnIndex)
Returns true.
Parameters:
columnIndex - (1,2,...)
Returns:
true
|
boolean |
isSearchable(int columnIndex)
Returns true.
|
boolean |
isSearchable(int columnIndex)
Returns true.
Parameters:
columnIndex - (1,2,...)
Returns:
true
|
boolean |
isSigned(int columnIndex)
Returns true.
|
boolean |
isSigned(int columnIndex)
Returns true.
Parameters:
columnIndex - (1,2,...)
Returns:
true
|
boolean |
isWritable(int columnIndex)
Returns false.
|
boolean |
isWritable(int columnIndex)
Returns false.
Parameters:
columnIndex - (1,2,...)
Returns:
false
|
boolean |
next()
Moves the cursor to the next row of the result set.
|
boolean |
next() throws SQLException
Moves the cursor to the next row of the result set.
Returns:
true if successful, false if there are no more rows
|
void |
setAutoClose(boolean autoClose)
Set the auto-close behavior.
|
void |
setAutoClose(boolean autoClose)
Set the auto-close behavior. If enabled (the default), the result set is
closed after reading the last row.
Parameters:
autoClose - the new value
|
boolean |
wasNull()
Returns whether the last column accessed was null.
|
boolean |
wasNull()
Returns whether the last column accessed was null.
Returns:
true if the last column accessed was null
|