All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.as400.access.AS400JDBCResultSet
java.lang.Object
|
+----com.ibm.as400.access.AS400JDBCResultSet
- public class AS400JDBCResultSet
- extends Object
- implements ResultSet
The AS400JDBCResultSet
class provides access to a table of data generated by a database
query. The table rows are retrieved in sequence. Within a row,
column values can be accessed in any order.
A result set maintains a cursor pointing to its current
row of data. Initially, the cursor is positioned before the
first row. next() moves the cursor
to the next row.
The get methods retrieve column values for the current row.
Values can be retrieved using either the index of the column
or by using the name of the column. In general, using the
column index is more efficient. Column indexes are numbered
starting with 1. Column names used as input to get methods
are not case sensitive. If several columns have the same name,
then the first matching column will be used.
In each get method, the driver attempts to convert the
underlying data to the specified Java type and returns a
suitable Java value. If such a conversion is not appropriate,
an SQLException is thrown.
A result set is automatically closed by the statement that
generated it when the statement is closed, executed again, or used
to retrieve the next result set from a sequence of multiple
result sets.
- See Also:
- AS400JDBCResultSetMetaData
-
clearWarnings()
- Clears all warnings that have been reported for the result set.
-
close()
- Releases the result set's resources immediately instead of
waiting for them to be automatically released.
-
finalize()
- Closes the result set if not explicitly closed by the caller.
-
findColumn(String)
- Returns the column index for the specified column name.
-
getAsciiStream(int)
- Returns the value of a column as a stream of ASCII
characters.
-
getAsciiStream(String)
- Returns the value of a column as a stream of ASCII
characters.
-
getBigDecimal(int, int)
- Returns the value of a column as a BigDecimal object.
-
getBigDecimal(String, int)
- Returns the value of a column as a BigDecimal object.
-
getBinaryStream(int)
- Returns the value of a column as a stream of uninterpreted
bytes.
-
getBinaryStream(String)
- Returns the value of a column as a stream of uninterpreted
bytes.
-
getBoolean(int)
- Returns the value of a column as a Java boolean value.
-
getBoolean(String)
- Returns the value of a column as a Java boolean value.
-
getByte(int)
- Returns the value of a column as a Java byte value.
-
getByte(String)
- Returns the value of a column as a Java byte value.
-
getBytes(int)
- Returns the value of a column as a Java byte array.
-
getBytes(String)
- Returns the value of a column as a Java byte array.
-
getCursorName()
- Returns the name of the SQL cursor in use by the result set.
-
getDate(int)
- Returns the value of a column as a java.sql.Date object.
-
getDate(String)
- Returns the value of a column as a java.sql.Date object.
-
getDouble(int)
- Returns the value of a column as a Java double value.
-
getDouble(String)
- Returns the value of a column as a Java double value.
-
getFloat(int)
- Returns the value of a column as a Java float value.
-
getFloat(String)
- Returns the value of a column as a Java float value.
-
getInt(int)
- Returns the value of a column as a Java int value.
-
getInt(String)
- Returns the value of a column as a Java int value.
-
getLong(int)
- Returns the value of a column as a Java long value.
-
getLong(String)
- Returns the value of a column as a Java long value.
-
getMetaData()
- Returns the
AS400JDBCResultSetMetaData object that describes the
result set's columns.
-
getObject(int)
- Returns the value of a column as a Java Object.
-
getObject(String)
- Returns the value of a column as a Java Object value.
-
getShort(int)
- Returns the value of a column as a Java short value.
-
getShort(String)
- Returns the value of a column as a Java short value.
-
getString(int)
- Returns the value of a column as a String object.
-
getString(String)
- Returns the value of a column as a String object.
-
getTime(int)
- Returns the value of a column as a java.sql.Time object.
-
getTime(String)
- Returns the value of a column as a java.sql.Time object.
-
getTimestamp(int)
- Returns the value of a column as a java.sql.Timestamp object.
-
getTimestamp(String)
- Returns the value of a column as a java.sql.Timestamp object.
-
getUnicodeStream(int)
- Returns the value of a column as a stream of Unicode
characters.
-
getUnicodeStream(String)
- Returns the value of a column as a stream of Unicode
characters.
-
getWarnings()
- Returns the first warning reported for the result set.
-
next()
- Positions the cursor to the next row of the result set.
-
toString()
- Returns the name of the SQL cursor in use by the result set.
-
wasNull()
- Indicates if the last column read has the value of SQL NULL.
clearWarnings
public void clearWarnings() throws SQLException
- Clears all warnings that have been reported for the result set.
After this call, getWarnings() returns
null until a new warning is reported for the result set.
- Throws: SQLException
- If an error occurs.
close
public void close() throws SQLException
- Releases the result set's resources immediately instead of
waiting for them to be automatically released.
- Throws: SQLException
- If an error occurs.
finalize
protected void finalize() throws Throwable
- Closes the result set if not explicitly closed by the caller.
- Throws: Throwable
- If an error occurs.
- Overrides:
- finalize in class Object
findColumn
public int findColumn(String columnName) throws SQLException
- Returns the column index for the specified column name.
- Parameters:
- columnName - The column name.
- Returns:
- The column index (1-based).
- Throws: SQLException
- If the result set is not open
or the column name is not found.
getAsciiStream
public InputStream getAsciiStream(int index) throws SQLException
- Returns the value of a column as a stream of ASCII
characters. This can be used to get values from columns
with SQL types CHAR, VARCHAR, BINARY, and VARBINARY.
All of the data in the returned stream must be read prior
to getting the value of any other column. The next call
to a get method implicitly closes the stream.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getAsciiStream
public InputStream getAsciiStream(String columnName) throws SQLException
- Returns the value of a column as a stream of ASCII
characters. This can be used to get values from columns
with SQL types CHAR, VARCHAR, BINARY, and VARBINARY.
All of the data in the returned stream must be read prior
to getting the value of any other column. The next call
to a get method implicitly closes the stream.
- Parameters:
- columnName - The column name.
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getBigDecimal
public BigDecimal getBigDecimal(int index,
int scale) throws SQLException
- Returns the value of a column as a BigDecimal object. This
can be used to get values from columns with SQL types
SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- index - The column index (1-based).
- scale - The number of digits after the decimal.
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid,
the scale is not valid, or the
requested conversion is not valid.
getBigDecimal
public BigDecimal getBigDecimal(String columnName,
int scale) throws SQLException
- Returns the value of a column as a BigDecimal object. This
can be used to get values from columns with SQL types
SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- columnName - The column name.
- scale - The number of digits after the decimal.
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found,
the scale is not valid, or the
requested conversion is not valid.
getBinaryStream
public InputStream getBinaryStream(int index) throws SQLException
- Returns the value of a column as a stream of uninterpreted
bytes. This can be used to get values from columns
with SQL types BINARY and VARBINARY. All of the data in
the returned stream must be read prior to getting the
value of any other column. The next call to a get method
implicitly closes the stream.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getBinaryStream
public InputStream getBinaryStream(String columnName) throws SQLException
- Returns the value of a column as a stream of uninterpreted
bytes. This can be used to get values from columns
with SQL types BINARY and VARBINARY. All of the data in
the returned stream must be read prior to getting the
value of any other column. The next call to a get method
implicitly closes the stream.
- Parameters:
- columnName - The column name.
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getBoolean
public boolean getBoolean(int index) throws SQLException
- Returns the value of a column as a Java boolean value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or false if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getBoolean
public boolean getBoolean(String columnName) throws SQLException
- Returns the value of a column as a Java boolean value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- columnName - The column name.
- Returns:
- The value or false if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getByte
public byte getByte(int index) throws SQLException
- Returns the value of a column as a Java byte value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or 0 if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getByte
public byte getByte(String columnName) throws SQLException
- Returns the value of a column as a Java byte value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- columnName - The column name.
- Returns:
- The value or 0 if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getBytes
public byte[] getBytes(int index) throws SQLException
- Returns the value of a column as a Java byte array.
This can be used to get values from columns with SQL
types BINARY and VARBINARY.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getBytes
public byte[] getBytes(String columnName) throws SQLException
- Returns the value of a column as a Java byte array.
This can be used to get values from columns with SQL
types BINARY and VARBINARY.
- Parameters:
- columnName - The column name.
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getCursorName
public String getCursorName() throws SQLException
- Returns the name of the SQL cursor in use by the result set.
In SQL, results are retrieved through a named cursor. The
current row of a result can be updated or deleted using a
positioned UPDATE or DELETE statement that references a
cursor name.
- Returns:
- The cursor name.
- Throws: SQLException
- If the result is not open.
- See Also:
- setCursorName
getDate
public Date getDate(int index) throws SQLException
- Returns the value of a column as a java.sql.Date object.
This can be used to get values from columns with SQL types
CHAR, VARCHAR, DATE, and TIMESTAMP.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getDate
public Date getDate(String columnName) throws SQLException
- Returns the value of a column as a java.sql.Date object.
This can be used to get values from columns with SQL types
CHAR, VARCHAR, DATE, and TIMESTAMP.
- Parameters:
- columnName - The column name.
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getDouble
public double getDouble(int index) throws SQLException
- Returns the value of a column as a Java double value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or 0 if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getDouble
public double getDouble(String columnName) throws SQLException
- Returns the value of a column as a Java double value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- columnName - The column name.
- Returns:
- The value or 0 if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getFloat
public float getFloat(int index) throws SQLException
- Returns the value of a column as a Java float value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or 0 if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getFloat
public float getFloat(String columnName) throws SQLException
- Returns the value of a column as a Java float value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- columnName - The column name.
- Returns:
- The value or 0 if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getInt
public int getInt(int index) throws SQLException
- Returns the value of a column as a Java int value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or 0 if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getInt
public int getInt(String columnName) throws SQLException
- Returns the value of a column as a Java int value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- columnName - The column name.
- Returns:
- The value or 0 if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getLong
public long getLong(int index) throws SQLException
- Returns the value of a column as a Java long value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or 0 if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getLong
public long getLong(String columnName) throws SQLException
- Returns the value of a column as a Java long value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- columnName - The column name.
- Returns:
- The value or 0 if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getMetaData
public ResultSetMetaData getMetaData() throws SQLException
- Returns the
AS400JDBCResultSetMetaData object that describes the
result set's columns.
- Returns:
- The meta data object.
- Throws: SQLException
- If the result set is not open.
getObject
public Object getObject(int index) throws SQLException
- Returns the value of a column as a Java Object.
This can be used to get values from columns with all
SQL types.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getObject
public Object getObject(String columnName) throws SQLException
- Returns the value of a column as a Java Object value.
This can be used to get values from columns with all
SQL types.
- Parameters:
- columnName - The column name.
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getShort
public short getShort(int index) throws SQLException
- Returns the value of a column as a Java short value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or 0 if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getShort
public short getShort(String columnName) throws SQLException
- Returns the value of a column as a Java short value.
This can be used to get values from columns with SQL
types SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL,
NUMERIC, CHAR, and VARCHAR.
- Parameters:
- columnName - The column name.
- Returns:
- The value or 0 if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getString
public String getString(int index) throws SQLException
- Returns the value of a column as a String object.
This can be used to get values from columns with any SQL
type.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getString
public String getString(String columnName) throws SQLException
- Returns the value of a column as a String object.
This can be used to get values from columns with any SQL
type.
- Parameters:
- columnName - The column name.
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getTime
public Time getTime(int index) throws SQLException
- Returns the value of a column as a java.sql.Time object.
This can be used to get values from columns with SQL types
CHAR, VARCHAR, TIME, and TIMESTAMP.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getTime
public Time getTime(String columnName) throws SQLException
- Returns the value of a column as a java.sql.Time object.
This can be used to get values from columns with SQL types
CHAR, VARCHAR, TIME, and TIMESTAMP.
- Parameters:
- columnName - The column name.
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getTimestamp
public Timestamp getTimestamp(int index) throws SQLException
- Returns the value of a column as a java.sql.Timestamp object.
This can be used to get values from columns with SQL types
CHAR, VARCHAR, DATE, and TIMESTAMP.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getTimestamp
public Timestamp getTimestamp(String columnName) throws SQLException
- Returns the value of a column as a java.sql.Timestamp object.
This can be used to get values from columns with SQL types
CHAR, VARCHAR, DATE, and TIMESTAMP.
- Parameters:
- columnName - The column name.
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getUnicodeStream
public InputStream getUnicodeStream(int index) throws SQLException
- Returns the value of a column as a stream of Unicode
characters. This can be used to get values from columns
with SQL types CHAR, VARCHAR, BINARY, and VARBINARY.
All of the data in the returned stream must be read prior
to getting the value of any other column. The next call
to a get method implicitly closes the stream.
- Parameters:
- index - The column index (1-based).
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the index is not valid, or the
requested conversion is not valid.
getUnicodeStream
public InputStream getUnicodeStream(String columnName) throws SQLException
- Returns the value of a column as a stream of Unicode
characters. This can be used to get values from columns
with SQL types CHAR, VARCHAR, BINARY, and VARBINARY.
All of the data in the returned stream must be read prior
to getting the value of any other column. The next call
to a get method implicitly closes the stream.
- Parameters:
- columnName - The column name.
- Returns:
- The value or null if the value is SQL NULL.
- Throws: SQLException
- If the result set is not open,
the column name is not found, or the
requested conversion is not valid.
getWarnings
public SQLWarning getWarnings() throws SQLException
- Returns the first warning reported for the result set.
Subsequent warnings may be chained to this warning.
- Returns:
- The first warning or null if no warnings
have been reported.
- Throws: SQLException
- If an error occurs.
- See Also:
- clearWarnings
next
public boolean next() throws SQLException
- Positions the cursor to the next row of the result set.
The result set's cursor is initially positioned before its
first row. The first call to next() makes the first row
the current row. Each subsequent call to next() advances
the cursor to the next row. If an InputStream from the
previous row is open, it is implicitly closed. In addition,
all warnings are cleared.
- Returns:
- true if the new current row is valid, false
if there are no more rows.
- Throws: SQLException
- If an error occurs.
toString
public String toString()
- Returns the name of the SQL cursor in use by the result set.
- Returns:
- The cursor name.
- Overrides:
- toString in class Object
wasNull
public boolean wasNull() throws SQLException
- Indicates if the last column read has the value of SQL NULL.
- Returns:
- true if the value is SQL NULL;
false otherwise.
- Throws: SQLException
- If the result set is not open.
All Packages Class Hierarchy This Package Previous Next Index