|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.as400.micro.JdbcMeLiveResultSet
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.
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 |
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.Wrapper |
---|
isWrapperFor, unwrap |
Field Detail |
---|
public static final byte ROW_CURRENT
public static final byte ROW_INSERT
public static final byte ROW_UPDATE
Method Detail |
---|
public void close() throws JdbcMeException
close
in interface ResultSet
JdbcMeException
- If an error occurs.public void deleteRow() throws JdbcMeException
deleteRow
in interface ResultSet
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.public String getString(int columnIndex) throws JdbcMeException
getString
in interface ResultSet
columnIndex
- The column index (1-based).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.public int getInt(int columnIndex) throws JdbcMeException
getInt
in interface ResultSet
columnIndex
- The column index (1-based).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.public void insertRow() throws JdbcMeException
insertRow
in interface ResultSet
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.public void moveToInsertRow() throws JdbcMeException
moveToInsertRow
in interface ResultSet
JdbcMeException
- If the result set is not open,
the result set is not scrollable,
the result set is not updatable,
or an error occurs.public void moveToCurrentRow() throws JdbcMeException
If an InputStream from the current row is open, it is implicitly closed. In addition, all warnings and pending updates are cleared.
moveToCurrentRow
in interface ResultSet
JdbcMeException
- If the result set is not open,
the result set is not scrollable,
or an error occurs.public boolean next() throws JdbcMeException
next
in interface ResultSet
JdbcMeException
- If the result set is not open,
or an error occurs.public boolean previous() throws JdbcMeException
previous
in interface ResultSet
JdbcMeException
- If the result set is not open,
the result set is not scrollable,
or an error occurs.public boolean relative(int rowNumber) throws JdbcMeException
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.
relative
in interface ResultSet
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.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.public boolean first() throws JdbcMeException
first
in interface ResultSet
JdbcMeException
- If the result set is not open,
the result set is not scrollable,
or an error occurs.public boolean last() throws JdbcMeException
last
in interface ResultSet
JdbcMeException
- If the result set is not open,
the result set is not scrollable,
or an error occurs.public boolean absolute(int rowNumber) throws JdbcMeException
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.
absolute
in interface ResultSet
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.JdbcMeException
- If the result set is not open,
the result set is not scrollable,
the row number is 0,
or an error occurs.public void updateString(int columnIndex, String value) throws JdbcMeException
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.
updateString
in interface ResultSet
columnIndex
- The column index (1-based).value
- The column value or null to update
the value to SQL NULL.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.public void updateInt(int columnIndex, int value) throws JdbcMeException
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.
updateInt
in interface ResultSet
columnIndex
- The column index (1-based).value
- The column value.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.public void updateRow() throws JdbcMeException
updateRow
in interface ResultSet
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.public ResultSetMetaData getMetaData() throws JdbcMeException
getMetaData
in interface ResultSet
JdbcMeException
- If an error occurs.public Statement getStatement() throws JdbcMeException
getStatement
in interface ResultSet
JdbcMeException
- If an error occurs.public int getType() throws JdbcMeException
getType
in interface ResultSet
JdbcMeException
- If the result set is not open.public int getConcurrency() throws JdbcMeException
getConcurrency
in interface ResultSet
JdbcMeException
- If the result set is not open.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |