com.ibm.as400.micro
Class JdbcMeOfflineResultSet

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

public class JdbcMeOfflineResultSet
extends Object
implements ResultSet

JdbcMeOfflineResultSet implements the java.sql.ResultSet interface as provided for a Java 2 Micro-Edition device over the top of an existing MIDP Record Store or a Palm OS database.

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


Field Summary
Modifier and Type Field and Description
static int AFTER_LAST_ROW
          Row position is after the last row of the result set.
static int BEFORE_FIRST_ROW
          Row position is before the first row of the result set.
 
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
 
Constructor Summary
Constructor and Description
JdbcMeOfflineResultSet(String dbName, int dbCreator, int dbType)
          Construct a result set based on the offline data indicated.
JdbcMeOfflineResultSet(String dbName, int dbCreator, int dbType, int numColumns, int[] columnTypes)
          Construct a result set based on the imported offline data records indicated.
 
Method Summary
Modifier and Type Method and Description
 boolean absolute(int row)
          Positions the cursor to an absolute row number.
 void close()
          Close the ResultSet and the offline database.
 void deleteRow()
          Delete the current row.
 void dumpDB(boolean dumpAsStrings)
          Dump out the current database (Using System.out.println).
 void dumpDB(JdbcMeOfflineData db, boolean dumpAsStrings)
          Dump out the specified database.
 boolean first()
          Positions the cursor to the first row.
 int getConcurrency()
          Return the concurrency of the result set.
 int getCurrentRow()
          Return the number of the current row in the offline DB.
 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()
          Return the type of result set.
 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.
 int numberOfRows()
          Return the number of ResultSet rows in the offline result set.
 boolean previous()
          Positions the cursor to the previous row.
 boolean relative(int rows)
          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

BEFORE_FIRST_ROW

public static final int BEFORE_FIRST_ROW
Row position is before the first row of the result set.

See Also:
Constant Field Values

AFTER_LAST_ROW

public static final int AFTER_LAST_ROW
Row position is after the last row of the result set.

See Also:
Constant Field Values
Constructor Detail

JdbcMeOfflineResultSet

public JdbcMeOfflineResultSet(String dbName,
                              int dbCreator,
                              int dbType)
                       throws JdbcMeException
Construct a result set based on the offline data indicated.

The offline data must have been created by JdbcMe (for example via JdbcMeStatement.executeToMIDPDB() or JdbcMeStatement.executeToPalmDB()).

No Connection or Statement is required when accessing a JdbcMeOfflineResultSet.

If the RecordStore was not created with JdbcMeStatement.executeToMIDPDB(), the constructor JdbcMeOfflineResultSet(String, int, int, int, int[]) should be used to allow you to define meta-data about the imported database.

Parameters:
dbName - The name of the offline database.
dbCreator - The unique offline database creator identifier.
dbType - The unique offline database type identifier.
Throws:
JdbcMeException - If an error occurs.

JdbcMeOfflineResultSet

public JdbcMeOfflineResultSet(String dbName,
                              int dbCreator,
                              int dbType,
                              int numColumns,
                              int[] columnTypes)
                       throws JdbcMeException
Construct a result set based on the imported offline data records indicated.

No Connection or Statement is required when accesing a JdbcMeOfflineResultSet.

An imported offline data store (Palm DB or MIDP record store) is created by some other application. The caller indicates the number of columns and the format of the data using the numColumns and columnTypes parameters.

The offline data must be a proper result set (i.e. number of records in the offline data must evenly divisible by the number of columns). The length of the 'columnTypes' array must equal the 'numColumns' parameter.

Parameters:
dbName - The name of the offline database.
dbCreator - The unique offline database creator identifier.
dbType - The unique offline database type identifier.
numColumns - The number of columns.
columnTypes - The column types.
Throws:
JdbcMeException - If an error occurs.
Method Detail

close

public void close()
           throws JdbcMeException
Close the ResultSet and the offline database.

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

deleteRow

public void deleteRow()
               throws JdbcMeException
Delete the current row.

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.

Note: This method is currently not implemented and will throw a JdbcMeException.

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.

Note: This method is currently not implemented and will throw a JdbcMeException.

Specified by:
moveToInsertRow in interface ResultSet
Throws:
JdbcMeException - Always thrown. This method is not implemented in an offline result set.

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.

Note: This method is currently not implemented and will throw a JdbcMeException.

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 rows)
                 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:
rows - 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 row)
                 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:
row - 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 updateString for the JdbcMeOfflineResultSet works rather differently than a standard result set, it updates the column specified by the 'columnIndex' parameter IMMEDIATELY, and IN PLACE. It does not require movement out of the current row, nor does it cause any cursor movement. It simply updates the value.

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 updateInt for the JdbcMeOfflineResultSet works rather differently than a standard result set, it updates the column specified by the 'columnIndex' parameter IMMEDIATELY, and IN PLACE. It does not require movement out of the current row, nor does it cause any cursor movement. It simply updates the value.

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.

Note: This method is currently not implemented.

Specified by:
updateRow in interface ResultSet
Throws:
JdbcMeException - This exception is never thrown.

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.

Note: This method returns null, no JdbcMeOfflineResultSet is ever owned by a statement.

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 - This exception is never thrown.

dumpDB

public void dumpDB(boolean dumpAsStrings)
            throws JdbcMeException
Dump out the current database (Using System.out.println). Optionally, convert the hex values to Strings so they are easier to view.

Parameters:
dumpAsStrings - true to convert the database hex values to strings; false otherwise.
Throws:
JdbcMeException - If an error occurs.

dumpDB

public void dumpDB(JdbcMeOfflineData db,
                   boolean dumpAsStrings)
            throws JdbcMeException
Dump out the specified database. Optionally, convert the values of each record to Strings so they are easier to view.

Parameters:
db - The database.
dumpAsStrings - true to convert the database hex values to strings; false otherwise.
Throws:
JdbcMeException - If an error occurs.

numberOfRows

public int numberOfRows()
Return the number of ResultSet rows in the offline result set. This number is not the same as the number of records in the offline data DB.

Returns:
The number of rows.

getCurrentRow

public int getCurrentRow()
Return the number of the current row in the offline DB. The first row is 1, BEFORE_FIRST_ROW or AFTER_LAST_ROW may also be returned.

Returns:
The current row index.

getType

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

All offline database result sets are TYPE_SCROLL_SENSITIVE.

Specified by:
getType in interface ResultSet
Returns:
The result set type, which is always TYPE_SCROLL_SENSITIVE.
Throws:
JdbcMeException - If the result set is not open.

getConcurrency

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

All offline database result sets are CONCUR_UPDATABLE.

Specified by:
getConcurrency in interface ResultSet
Returns:
The result set concurrency, which is always CONCUR_UPDATABLE.
Throws:
JdbcMeException - If the result set is not open.