Top Description Fields Methods
org.apache.derby.iapi.sql

public Interface ResultSet

Known Direct Subinterfaces
org.apache.derby.iapi.sql.execute.CursorResultSet, org.apache.derby.iapi.sql.execute.NoPutResultSet, org.apache.derby.iapi.sql.execute.TargetResultSet
Known Direct Implementers
org.apache.derby.impl.sql.execute.NoRowsResultSetImpl
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.sql.execute.ExecRow, .NoPutResultSet, org.apache.derby.iapi.sql.Row, java.sql.Timestamp, .SQLWarning, org.w3c.dom.Element

The ResultSet interface provides a method to tell whether a statement returns rows, and if so, a method to get the rows. It also provides a method to get metadata about the contents of the rows. It also provide a method to accept rows as input.

There is no single implementation of the ResultSet interface. Instead, the various support operations involved in executing statements implement this interface.

Although ExecRow is used on the interface, it is not available to users of the API. They should use Row, the exposed super-interface of ExecRow. [I couldn't find another way to perform this mapping...]

Valid transitions:

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int

Method Summary

Modifier and TypeMethod and Description
public void
addWarning(SQLWarning
the warning to add
w
)

Add a warning to this result set.

public boolean

Returns:

true if at the requested position.
checkRowPosition
(int
The desired position type
isType
)

Determine if the result set is at one of the positions according to the constants above (ISBEFOREFIRST etc).

public void
cleanUp()

Tells the system to clean up on an error.

public void
clearCurrentRow()

Clear the current row.

public void
close()

Tells the system that there will be no more calls to getNextRow() (until the next open() call), so it can free up the resources associated with the ResultSet.

public void
finish()

Tells the system that there will be no more access to any database information via this result set; in particular, no more calls to open().

public ExecRow

Returns:

The row at the absolute position, or NULL if no such position.
getAbsoluteRow
(int
The position.
row
)

Returns the row at the absolute position from the query, and returns NULL when there is no such position.

public Activation
public ResultSet

Returns:

NoPutResultSet NoPutResultSets for rows inserted into the table.
getAutoGeneratedKeysResultset
()

ResultSet for rows inserted into the table (contains auto-generated keys columns only)

public Timestamp

Returns:

Timestamp The Timestamp for the beginning of execution.
getBeginExecutionTimestamp
()

Get the Timestamp for the beginning of execution.

public String

Returns:

A String with the name of the cursor, if any. Returns NULL if this is not a cursor statement.
getCursorName
()

Returns the name of the cursor, if this is cursor statement of some type (declare, open, fetch, positioned update, positioned delete, close).

public Timestamp

Returns:

Timestamp The Timestamp for the end of execution.
getEndExecutionTimestamp
()

Get the Timestamp for the end of execution.

public long

Returns:

long The execution time in milliseconds.
getExecuteTime
()

Get the execution time in milliseconds.

public ExecRow

Returns:

The first row, or NULL if no rows.
getFirstRow
()

Returns the first row from the query, and returns NULL when there are no rows.

public ExecRow

Returns:

The last row, or NULL if no rows.
getLastRow
()

Returns the last row from the query, and returns NULL when there are no rows.

public ExecRow

Returns:

The next row, or NULL if no more rows.
getNextRow
()

Returns the next row from the query, and returns NULL when there are no more rows.

public ExecRow

Returns:

The previous row, or NULL if no more previous rows.
getPreviousRow
()

Returns the previous row from the query, and returns NULL when there are no more previous rows.

public ExecRow

Returns:

The row at the relative position, or NULL if no such position.
getRelativeRow
(int
The position.
row
)

Returns the row at the relative position from the current cursor position, and returns NULL when there is no such position.

public ResultDescription

Returns:

A ResultDescription describing the results of the statement.
getResultDescription
()

Returns a ResultDescription object, which describes the results of the statement this ResultSet is in. This will *not* be a description of this particular ResultSet, if this is not the outermost ResultSet.

public int

Returns:

the row number, or 0 if not on a row
getRowNumber
()

Returns the row number of the current row.

public NoPutResultSet[]

Returns:

NoPutResultSet[] Array of NoPutResultSets for subqueries.
getSubqueryTrackingArray
(int
The size of the array (For allocation on demand.)
numSubqueries
)

Get the subquery ResultSet tracking array from the top ResultSet.

public long

Returns:

long The total amount of time spent (in milliseconds).
getTimeSpent
(int
CURRENT_RESULTSET_ONLY - time spent only in this ResultSet ENTIRE_RESULTSET_TREE - time spent in this ResultSet and below.
type
)

Return the total amount of time spent in this ResultSet

public SQLWarning

Returns:

the execution warnings
getWarnings
()

Return the set of warnings generated during the execution of this result set.

public boolean

Returns:

true if the ResultSet has been closed.
isClosed
()

Find out if the ResultSet is closed or not.

public long

Returns:

The number of rows affect by the statement, so far.
modifiedRowCount
()

Returns the number of rows affected by the statement.

public void
open()

Needs to be called before the result set will do anything.

public boolean

Returns:

TRUE if the statement returns rows, FALSE if not.
returnsRows
()

Returns TRUE if the statement returns rows (i.e. is a SELECT or FETCH statement), FALSE if it returns no rows.

public ExecRow

Returns:

NULL.
setAfterLastRow
()

Sets the current position to after the last row and returns NULL because there is no current row.

public ExecRow

Returns:

NULL.
setBeforeFirstRow
()

Sets the current position to before the first row and returns NULL because there is no current row.

public Element

Returns:

the content as an element with the given tag name
toXML
(Element
Node to put content into.
parentNode
,
String
Element tag for content
tag
)

Produce an xml image of this ResultSet and its descendant ResultSets.

Field Detail

CURRENT_RESULTSET_ONLYback to summary
public static final int CURRENT_RESULTSET_ONLY
ENTIRE_RESULTSET_TREEback to summary
public static final int ENTIRE_RESULTSET_TREE
ISAFTERLASTback to summary
public static final int ISAFTERLAST
ISBEFOREFIRSTback to summary
public static final int ISBEFOREFIRST
ISFIRSTback to summary
public static final int ISFIRST
ISLASTback to summary
public static final int ISLAST

Method Detail

addWarningback to summary
public void addWarning(SQLWarning w)

Add a warning to this result set.

Parameters
w:SQLWarning

the warning to add

checkRowPositionback to summary
public boolean checkRowPosition(int isType) throws StandardException

Determine if the result set is at one of the positions according to the constants above (ISBEFOREFIRST etc). Only valid and called for scrollable cursors.

Parameters
isType:int

The desired position type

Returns:boolean

true if at the requested position.

Exceptions
StandardException:
Thrown on error.
cleanUpback to summary
public void cleanUp() throws StandardException

Tells the system to clean up on an error.

Exceptions
StandardException:
Thrown on error.
clearCurrentRowback to summary
public void clearCurrentRow()

Clear the current row. The cursor keeps it current position, however it cannot be used for positioned updates or deletes until a fetch is done. This is done after a commit on holdable result sets. A fetch is achieved by calling one of the positioning methods: getLastRow(), getNextRow(), getPreviousRow(), getFirstRow(), getRelativeRow(..) or getAbsoluteRow(..).

closeback to summary
public void close() throws StandardException

Tells the system that there will be no more calls to getNextRow() (until the next open() call), so it can free up the resources associated with the ResultSet.

Exceptions
StandardException:
Thrown on error.
finishback to summary
public void finish() throws StandardException

Tells the system that there will be no more access to any database information via this result set; in particular, no more calls to open(). Will close the result set if it is not already closed.

Exceptions
StandardException:
on error
getAbsoluteRowback to summary
public ExecRow getAbsoluteRow(int row) throws StandardException

Returns the row at the absolute position from the query, and returns NULL when there is no such position. (Negative position means from the end of the result set.) Moving the cursor to an invalid position leaves the cursor positioned either before the first row (negative position) or after the last row (positive position).

Note

An exception will be thrown on 0.

Parameters
row:int

The position.

Returns:ExecRow

The row at the absolute position, or NULL if no such position.

Exceptions
StandardException:
Thrown on failure
See Also
Row
getActivationback to summary
public Activation getActivation()
getAutoGeneratedKeysResultsetback to summary
public ResultSet getAutoGeneratedKeysResultset()

ResultSet for rows inserted into the table (contains auto-generated keys columns only)

Returns:ResultSet

NoPutResultSet NoPutResultSets for rows inserted into the table.

getBeginExecutionTimestampback to summary
public Timestamp getBeginExecutionTimestamp()

Get the Timestamp for the beginning of execution.

Returns:Timestamp

Timestamp The Timestamp for the beginning of execution.

getCursorNameback to summary
public String getCursorName()

Returns the name of the cursor, if this is cursor statement of some type (declare, open, fetch, positioned update, positioned delete, close).

Returns:String

A String with the name of the cursor, if any. Returns NULL if this is not a cursor statement.

getEndExecutionTimestampback to summary
public Timestamp getEndExecutionTimestamp()

Get the Timestamp for the end of execution.

Returns:Timestamp

Timestamp The Timestamp for the end of execution.

getExecuteTimeback to summary
public long getExecuteTime()

Get the execution time in milliseconds.

Returns:long

long The execution time in milliseconds.

getFirstRowback to summary
public ExecRow getFirstRow() throws StandardException

Returns the first row from the query, and returns NULL when there are no rows.

Returns:ExecRow

The first row, or NULL if no rows.

Exceptions
StandardException:
Thrown on failure
See Also
Row
getLastRowback to summary
public ExecRow getLastRow() throws StandardException

Returns the last row from the query, and returns NULL when there are no rows.

Returns:ExecRow

The last row, or NULL if no rows.

Exceptions
StandardException:
Thrown on failure
See Also
Row
getNextRowback to summary
public ExecRow getNextRow() throws StandardException

Returns the next row from the query, and returns NULL when there are no more rows.

Returns:ExecRow

The next row, or NULL if no more rows.

Exceptions
StandardException:
Thrown on failure
See Also
Row
getPreviousRowback to summary
public ExecRow getPreviousRow() throws StandardException

Returns the previous row from the query, and returns NULL when there are no more previous rows.

Returns:ExecRow

The previous row, or NULL if no more previous rows.

Exceptions
StandardException:
Thrown on failure
See Also
Row
getRelativeRowback to summary
public ExecRow getRelativeRow(int row) throws StandardException

Returns the row at the relative position from the current cursor position, and returns NULL when there is no such position. (Negative position means toward the beginning of the result set.) Moving the cursor to an invalid position leaves the cursor positioned either before the first row (negative position) or after the last row (positive position).

Note

0 is valid.

Note

An exception is thrown if the cursor is not currently positioned on a row.

Parameters
row:int

The position.

Returns:ExecRow

The row at the relative position, or NULL if no such position.

Exceptions
StandardException:
Thrown on failure
See Also
Row
getResultDescriptionback to summary
public ResultDescription getResultDescription()

Returns a ResultDescription object, which describes the results of the statement this ResultSet is in. This will *not* be a description of this particular ResultSet, if this is not the outermost ResultSet.

Returns:ResultDescription

A ResultDescription describing the results of the statement.

getRowNumberback to summary
public int getRowNumber()

Returns the row number of the current row. Row numbers start from 1 and go to 'n'. Corresponds to row numbering used to position current row in the result set (as per JDBC). Only valid and called for scrollable cursors.

Returns:int

the row number, or 0 if not on a row

getSubqueryTrackingArrayback to summary
public NoPutResultSet[] getSubqueryTrackingArray(int numSubqueries)

Get the subquery ResultSet tracking array from the top ResultSet. (Used for tracking open subqueries when closing down on an error.)

Parameters
numSubqueries:int

The size of the array (For allocation on demand.)

Returns:NoPutResultSet[]

NoPutResultSet[] Array of NoPutResultSets for subqueries.

getTimeSpentback to summary
public long getTimeSpent(int type)

Return the total amount of time spent in this ResultSet

Parameters
type:int

CURRENT_RESULTSET_ONLY - time spent only in this ResultSet ENTIRE_RESULTSET_TREE - time spent in this ResultSet and below.

Returns:long

long The total amount of time spent (in milliseconds).

getWarningsback to summary
public SQLWarning getWarnings()

Return the set of warnings generated during the execution of this result set. The warnings are cleared once this call returns.

Returns:SQLWarning

the execution warnings

isClosedback to summary
public boolean isClosed()

Find out if the ResultSet is closed or not. Will report true for result sets that do not return rows.

Returns:boolean

true if the ResultSet has been closed.

modifiedRowCountback to summary
public long modifiedRowCount()

Returns the number of rows affected by the statement. Only valid of returnsRows() returns false. For other DML statements, it returns the number of rows modified by the statement. For statements that do not affect rows (like DDL statements), it returns zero.

Returns:long

The number of rows affect by the statement, so far.

openback to summary
public void open() throws StandardException

Needs to be called before the result set will do anything. Need to call before getNextRow(), or for a result set that doesn't return rows, this is the call that will cause all the work to be done.

Exceptions
StandardException:
Thrown on failure
returnsRowsback to summary
public boolean returnsRows()

Returns TRUE if the statement returns rows (i.e. is a SELECT or FETCH statement), FALSE if it returns no rows.

Returns:boolean

TRUE if the statement returns rows, FALSE if not.

setAfterLastRowback to summary
public ExecRow setAfterLastRow() throws StandardException

Sets the current position to after the last row and returns NULL because there is no current row.

Returns:ExecRow

NULL.

Exceptions
StandardException:
Thrown on failure
See Also
Row
setBeforeFirstRowback to summary
public ExecRow setBeforeFirstRow() throws StandardException

Sets the current position to before the first row and returns NULL because there is no current row.

Returns:ExecRow

NULL.

Exceptions
StandardException:
Thrown on failure
See Also
Row
toXMLback to summary
public Element toXML(Element parentNode, String tag) throws Exception

Produce an xml image of this ResultSet and its descendant ResultSets. Appends an element to the parentNode and returns the appended element.

Parameters
parentNode:Element

Node to put content into.

tag:String

Element tag for content

Returns:Element

the content as an element with the given tag name

Exceptions
Exception:
on error