Logo Search packages:      
Sourcecode: mysql-connector-java version File versions

boolean com::mysql::jdbc::ResultSet::absolute ( int  row  )  throws SQLException [inline]

JDBC 2.0

Move to an absolute row number in the result set.

If row is positive, moves to an absolute row with respect to the beginning of the result set. The first row is row 1, the second is row 2, etc.

If row is negative, moves to an absolute row position with respect to the end of result set. For example, calling absolute(-1) positions the cursor on the last row, absolute(-2) indicates the next-to-last row, etc.

An attempt to position the cursor beyond the first/last row in the result set, leaves the cursor before/after the first/last row, respectively.

Note: Calling absolute(1) is the same as calling first(). Calling absolute(-1) is the same as calling last().

Parameters:
row the row number to move to
Returns:
true if on the result set, false if off.
Exceptions:
SQLException if a database-access error occurs, or row is 0, or result set type is TYPE_FORWARD_ONLY.

Reimplemented in com::mysql::jdbc::UpdatableResultSet.

Definition at line 2532 of file ResultSet.java.

                                                         {
        checkClosed();

        boolean b;

        if (this.rowData.size() == 0) {
            b = false;
        } else {
            if (row == 0) {
                throw new SQLException(Messages.getString(
                        "ResultSet.Cannot_absolute_position_to_row_0_110"), //$NON-NLS-1$
                    SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
            }

            if (this.onInsertRow) {
                  this.onInsertRow = false;
            }

            if (this.doingUpdates) {
                  this.doingUpdates = false;
            }

            if (row == 1) {
                b = first();
            } else if (row == -1) {
                b = last();
            } else if (row > this.rowData.size()) {
                afterLast();
                b = false;
            } else {
                if (row < 0) {
                    // adjust to reflect after end of result set
                    int newRowPosition = this.rowData.size() + row + 1;

                    if (newRowPosition <= 0) {
                        beforeFirst();
                        b = false;
                    } else {
                        b = absolute(newRowPosition);
                    }
                } else {
                    row--; // adjust for index difference
                    this.rowData.setCurrentRow(row);
                    this.thisRow = this.rowData.getAt(row);
                    b = true;
                }
            }
        }

        return b;
    }


Generated by  Doxygen 1.6.0   Back to index