com.ibm.as400.micro
Class JdbcMeLiveResultSet

java.lang.Object
  extended by com.ibm.as400.micro.JdbcMeLiveResultSet
All Implemented Interfaces:
ResultSet, Wrapper

public class JdbcMeLiveResultSet
extends Object
implements ResultSet

The JdbcMeLiveResultSet class provides access to a table of data generated by a database query.

A result set maintains a cursor pointing to its current row of data. Initially, the cursor is positioned before the first row. If the result set is scrollable, use any of the cursor positioning methods to move the cursor within the result set. If the result set is not scrollable, then only use next() to move the cursor.

The get methods retrieve column values for the current row. Values can be retrieved using either the column index or the column name. In general, using the column index is more efficient. Column indexes are numbered starting with 1. Column names are not case sensitive. If several columns have the same name, then the first matching column is used.

Columns can have two names: a column name ("long name") and a system column name ("short name"). The get methods and findColumn() only support using the column name.

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, a JdbcMeException is thrown.

If the result set is updatable, the update methods modify column values for the current row in the result set, but not in the underlying database. updateRow() causes all updates to the current row to be written to the database. Use deleteRow() to delete the current row in the database.

For updatable result sets, there is also an insert row, which is used as a staging area for the contents of a new row. Use moveToInsertRow() to position the cursor to the insert row. Once all updates to the insert row have been made, use insertRow() to insert the row into the database.

In the following cases, result sets are always read only regardless of the concurrency set in the statement:

In the following cases, result sets are always forward only regardless of the type set in the statement:

A result set is automatically closed by the statement that generated it when the statement is closed, run again, or used to retrieve the next result set from a sequence of multiple result sets. To close the result set explicitly, call the close() method.

Note: Since Java 2 Micro-Edition does not include java.sql, JdbcMeLiveResultSet implements the java.sql package that is also part of this driver.


Field Summary
Modifier and Type Field and Description
static byte ROW_CURRENT
           
static byte ROW_INSERT
           
static byte ROW_UPDATE
           
 
Fields inherited from interface java.sql.ResultSet
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE
 
Method Summary
Modifier and Type Method and Description
 boolean absolute(int rowNumber)
          Positions the cursor to an absolute row number.
 void close()
          Releases the result set's resources.
 void deleteRow()
          Deletes the current row from the result set and the database.
 boolean first()
          Positions the cursor to the first row.
 int getConcurrency()
          Returns the result set concurrency.
 int getInt(int columnIndex)
          Returns the value of a column as a Java int value.
 ResultSetMetaData getMetaData()
          Returns the ResultSetMetaData object that describes the result set's columns.
 Statement getStatement()
          Returns the statement for this result set.
 String getString(int columnIndex)
          Returns the value of a column as a String object.
 int getType()
          Returns the result set type.
 void insertRow()
          Inserts the contents of the insert row into the result set and the database.
 boolean last()
          Positions the cursor to the last row.
 void moveToCurrentRow()
          Positions the cursor to the current row.
 void moveToInsertRow()
          Positions the cursor to the insert row.
 boolean next()
          Positions the cursor to the next row.
 boolean previous()
          Positions the cursor to the previous row.
 boolean relative(int rowNumber)
          Positions the cursor to a relative row number.
 void updateInt(int columnIndex, int value)
          Updates a column in the current row using a Java int value.
 void updateRow()
          Updates the database with the new contents of the current row.
 void updateString(int columnIndex, String value)
          Updates a column in the current row using a String value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.sql.ResultSet
afterLast, beforeFirst, cancelRowUpdates, clearWarnings, findColumn, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getHoldability, getInt, getLong, getLong, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getObject, getObject, getRef, getRef, getRow, getRowId, getRowId, getShort, getShort, getSQLXML, getSQLXML, getString, getTime, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getTimestamp, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, refreshRow, rowDeleted, rowInserted, rowUpdated, setFetchDirection, setFetchSize, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateLong, updateLong, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp, wasNull
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

Field Detail

ROW_CURRENT

public static final byte ROW_CURRENT
See Also:
Constant Field Values

ROW_INSERT

public static final byte ROW_INSERT
See Also:
Constant Field Values

ROW_UPDATE

public static final byte ROW_UPDATE
See Also:
Constant Field Values
Method Detail

close

public void close()
           throws JdbcMeException
Releases the result set's resources.

Specified by:
close in interface ResultSet
Throws:
JdbcMeException - If an error occurs.

deleteRow

public void deleteRow()
               throws JdbcMeException
Deletes the current row from the result set and the database. After deleting a row, the cursor position is no longer valid, so it must be explicitly repositioned.

Specified by:
deleteRow in interface ResultSet
Throws:
JdbcMeException - If the result set is not open, the result set is not updatable, the cursor is not positioned on a row, the cursor is positioned on the insert row, or an error occurs.

getString

public String getString(int columnIndex)
                 throws JdbcMeException
Returns the value of a column as a String object. This can be used to get values from columns with any SQL type.

Specified by:
getString in interface ResultSet
Parameters:
columnIndex - The column index (1-based).
Returns:
The column value or null if the value is SQL NULL.
Throws:
JdbcMeException - If the result set is not open, the cursor is not positioned on a row, the column index is not valid, or the requested conversion is not valid.

getInt

public int getInt(int columnIndex)
           throws JdbcMeException
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, BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, CHAR, and VARCHAR.

Specified by:
getInt in interface ResultSet
Parameters:
columnIndex - The column index (1-based).
Returns:
The column value or 0 if the value is SQL NULL.
Throws:
JdbcMeException - If the result set is not open, the cursor is not positioned on a row, the column index is not valid, or the requested conversion is not valid.

insertRow

public void insertRow()
               throws JdbcMeException
Inserts the contents of the insert row into the result set and the database.

Specified by:
insertRow in interface ResultSet
Throws:
JdbcMeException - If the result set is not open, the result set is not updatable, the cursor is not positioned on the insert row, a column that is not nullable was not specified, or an error occurs.

moveToInsertRow

public void moveToInsertRow()
                     throws JdbcMeException
Positions the cursor to the insert row. If an InputStream from the current row is open, it is implicitly closed. In addition, all warnings and pending updates are cleared.

Specified by:
moveToInsertRow in interface ResultSet
Throws:
JdbcMeException - If the result set is not open, the result set is not scrollable, the result set is not updatable, or an error occurs.

moveToCurrentRow

public void moveToCurrentRow()
                      throws JdbcMeException
Positions the cursor to the current row. This is the row where the cursor was positioned before moving it to the insert row. If the cursor is not on the insert row, then this has no effect.

If an InputStream from the current row is open, it is implicitly closed. In addition, all warnings and pending updates are cleared.

Specified by:
moveToCurrentRow in interface ResultSet
Throws:
JdbcMeException - If the result set is not open, the result set is not scrollable, or an error occurs.

next

public boolean next()
             throws JdbcMeException
Positions the cursor to the next row. If an InputStream from the current row is open, it is implicitly closed. In addition, all warnings and pending updates are cleared.

Specified by:
next in interface ResultSet
Returns:
true if the requested cursor position is valid; false if there are no more rows.
Throws:
JdbcMeException - If the result set is not open, or an error occurs.

previous

public boolean previous()
                 throws JdbcMeException
Positions the cursor to the previous row. If an InputStream from the current row is open, it is implicitly closed. In addition, all warnings and pending updates are cleared.

Specified by:
previous in interface ResultSet
Returns:
true if the requested cursor position is valid; false otherwise.
Throws:
JdbcMeException - If the result set is not open, the result set is not scrollable, or an error occurs.

relative

public boolean relative(int rowNumber)
                 throws JdbcMeException
Positions the cursor to a relative row number.

Attempting to move beyond the first row positions the cursor before the first row. Attempting to move beyond the last row positions the cursor after the last row.

If an InputStream from the current row is open, it is implicitly closed. In addition, all warnings and pending updates are cleared.

Specified by:
relative in interface ResultSet
Parameters:
rowNumber - The relative row number. If the relative row number is positive, this positions the cursor after the current position. If the relative row number is negative, this positions the cursor before the current position. If the relative row number is 0, then the cursor position does not change.
Returns:
true if the requested cursor position is valid, false otherwise.
Throws:
JdbcMeException - If the result set is not open, the result set is not scrollable, the cursor is not positioned on a valid row, or an error occurs.

first

public boolean first()
              throws JdbcMeException
Positions the cursor to the first row. If an InputStream from the current row is open, it is implicitly closed. In addition, all warnings and pending updates are cleared.

Specified by:
first in interface ResultSet
Returns:
true if the requested cursor position is valid; false otherwise.
Throws:
JdbcMeException - If the result set is not open, the result set is not scrollable, or an error occurs.

last

public boolean last()
             throws JdbcMeException
Positions the cursor to the last row. If an InputStream from the current row is open, it is implicitly closed. In addition, all warnings and pending updates are cleared.

Specified by:
last in interface ResultSet
Returns:
true if the requested cursor position is valid; false otherwise.
Throws:
JdbcMeException - If the result set is not open, the result set is not scrollable, or an error occurs.

absolute

public boolean absolute(int rowNumber)
                 throws JdbcMeException
Positions the cursor to an absolute row number.

Attempting to move any number of positions before the first row positions the cursor to before the first row. Attempting to move beyond the last row positions the cursor after the last row.

If an InputStream from the current row is open, it is implicitly closed. In addition, all warnings and pending updates are cleared.

Specified by:
absolute in interface ResultSet
Parameters:
rowNumber - The absolute row number. If the absolute row number is positive, this positions the cursor with respect to the beginning of the result set. If the absolute row number is negative, this positions the cursor with respect to the end of result set.
Returns:
true if the requested cursor position is valid; false otherwise.
Throws:
JdbcMeException - If the result set is not open, the result set is not scrollable, the row number is 0, or an error occurs.

updateString

public void updateString(int columnIndex,
                         String value)
                  throws JdbcMeException
Updates a column in the current row using a String value. The driver converts this to an SQL VARCHAR value.

This does not update the database directly. Instead, it updates a copy of the data in memory. Call updateRow() or insertRow() to update the database.

Specified by:
updateString in interface ResultSet
Parameters:
columnIndex - The column index (1-based).
value - The column value or null to update the value to SQL NULL.
Throws:
JdbcMeException - If the result set is not open, the result set is not updatable, the cursor is not positioned on a row, the column index is not valid, or the requested conversion is not valid.

updateInt

public void updateInt(int columnIndex,
                      int value)
               throws JdbcMeException
Updates a column in the current row using a Java int value. The driver converts this to an SQL INTEGER value.

This does not update the database directly. Instead, it updates a copy of the data in memory. Call updateRow() or insertRow() to update the database.

Specified by:
updateInt in interface ResultSet
Parameters:
columnIndex - The column index (1-based).
value - The column value.
Throws:
JdbcMeException - If the result set is not open, the result set is not updatable, the cursor is not positioned on a row, the column index is not valid, or the requested conversion is not valid.

updateRow

public void updateRow()
               throws JdbcMeException
Updates the database with the new contents of the current row.

Specified by:
updateRow in interface ResultSet
Throws:
JdbcMeException - If the result set is not open, the result set is not updatable, the cursor is not positioned on a row, the cursor is positioned on the insert row, or an error occurs.

getMetaData

public ResultSetMetaData getMetaData()
                              throws JdbcMeException
Returns the ResultSetMetaData object that describes the result set's columns.

Specified by:
getMetaData in interface ResultSet
Returns:
The metadata object.
Throws:
JdbcMeException - If an error occurs.

getStatement

public Statement getStatement()
                       throws JdbcMeException
Returns the statement for this result set.

Specified by:
getStatement in interface ResultSet
Returns:
The statement for this result set, or null if the result set was returned by a DatabaseMetaData catalog method.
Throws:
JdbcMeException - If an error occurs.

getType

public int getType()
            throws JdbcMeException
Returns the result set type.

Specified by:
getType in interface ResultSet
Returns:
The result set type. Valid values are:
  • TYPE_FORWARD_ONLY
  • TYPE_SCROLL_INSENSITIVE
  • TYPE_SCROLL_SENSITIVE
Throws:
JdbcMeException - If the result set is not open.

getConcurrency

public int getConcurrency()
                   throws JdbcMeException
Returns the result set concurrency.

Specified by:
getConcurrency in interface ResultSet
Returns:
The result set concurrency. Valid values are:
  • CONCUR_READ_ONLY
  • CONCUR_UPDATABLE
Throws:
JdbcMeException - If the result set is not open.