⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resultset.java

📁 SearchPathServer
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
			_thisRow = null;
		}
	}

	/**
	 * JDBC 2.0
	 *
	 * <p>Moves to the first row in the result set.  
	 *
	 * @return true if on a valid row, false if no rows in the result set.
	 * @exception SQLException if a database-access error occurs, or
	 * result set type is TYPE_FORWARD_ONLY.
	 */

	public  boolean first() throws SQLException {
		if (Driver.trace) {
			Object[] args = {
			};
			Debug.methodCall(this, "first", args);
		}
		if (_on_insert_row) {
			_on_insert_row = false;
		}

		if (_rows.size() == 0) {
			return false;
		}
		else {
			if (_doing_updates) {
				_doing_updates = false;
				
			}

			_currentRow = 0;
			_thisRow = (byte[][]) _rows.elementAt(_currentRow);

			return true;
		}
	}

	/**
	 * JDBC 2.0
	 *
	 * <p>Moves to the last row in the result set.  
	 *
	 * @return true if on a valid row, false if no rows in the result set.
	 * @exception SQLException if a database-access error occurs, or
	 * result set type is TYPE_FORWARD_ONLY.
	 */

	public  boolean last() throws SQLException {
		if (Driver.trace) {
			Object[] args = {
			};
			Debug.methodCall(this, "last", args);
		}

		if (_rows.size() == 0) {
			return false;
		}
		else {
			if (_on_insert_row) {
				_on_insert_row = false;
			}

			if (_doing_updates) {
				_doing_updates = false;
				
			}

			_currentRow = _rows.size() - 1;
			_thisRow = (byte[][]) _rows.elementAt(_currentRow);

			return true;
		}
	}

	/**
	 * JDBC 2.0
	 *
	 * <p>Determine the current row number.  The first row is number 1, the
	 * second number 2, etc.  
	 *
	 * @return the current row number, else return 0 if there is no 
	 * current row
	 * @exception SQLException if a database-access error occurs.
	 */

	public  int getRow() throws SQLException {
		if (Driver.trace) {
			Object[] args = {
			};
			Debug.methodCall(this, "getRow", args);
		}

		int row = 0;
		
		if (_currentRow < 0 || _currentRow >= _rows.size() || _rows.size() == 0) {
			row = 0;
		}
		else {
			row = _currentRow + 1;
		}
		
		if (Driver.trace) {
			Debug.returnValue(this, "getRow", new Integer(row));
		}
		
		return row;
	}

	/**
	 * JDBC 2.0
	 *
	 * <p>Move to an absolute row number in the result set.
	 *
	 * <p>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. 
	 *
	 * <p>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.
	 *
	 * <p>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.
	 *
	 * <p>Note: Calling absolute(1) is the same as calling first().
	 * Calling absolute(-1) is the same as calling last().
	 *
	 * @return true if on the result set, false if off.
	 * @exception SQLException if a database-access error occurs, or 
	 * row is 0, or result set type is TYPE_FORWARD_ONLY.
	 */

	public  boolean absolute(int row) throws SQLException {
		
		if (Driver.trace) {
			Object[] args = { new Integer(row)};
			Debug.methodCall(this, "absolute", args);
		}
		
		boolean b;
		
		if (_rows.size() == 0) {
			b = false;
		}
		else
		{

		if (row == 0) {
			throw new SQLException("Cannot absolute position to row 0", "S1009");
		}

		if (_on_insert_row) {
			_on_insert_row = false;
		}

		if (_doing_updates) {
			_doing_updates = false;
			
		}

		if (row == 1) {
			b = first();
		}
		else if (row == -1) {
			b = last();
			
		}
		else if (row > _rows.size()) {
			afterLast();

			b = false;
		}
		else {
			if (row < 0) {

				// adjust to reflect after end of result set
				int new_row_position = _rows.size() + row + 1;

				if (new_row_position <= 0) {
					beforeFirst();

					b = false;
				}
				else {
					b = absolute(new_row_position);
				}
			}
			else {
				row--; // adjust for index difference
				_currentRow = row;
				_thisRow = (byte[][]) _rows.elementAt(_currentRow);

				b = true;
			}
		}
		}
		
		if (Driver.trace) {
			Debug.returnValue(this, "absolute", new Boolean(b));
		}
		
		return b;
	}

	/**
	 * JDBC 2.0
	 *
	 * <p>Moves a relative number of rows, either positive or negative.
	 * Attempting to move beyond the first/last row in the
	 * result set positions the cursor before/after the
	 * the first/last row. Calling relative(0) is valid, but does
	 * not change the cursor position.
	 *
	 * <p>Note: Calling relative(1) is different than calling next()
	 * since is makes sense to call next() when there is no current row,
	 * for example, when the cursor is positioned before the first row
	 * or after the last row of the result set.
	 *
	 * @return true if on a row, false otherwise.
	 * @exception SQLException if a database-access error occurs, or there
	 * is no current row, or result set type is TYPE_FORWARD_ONLY.
	 */

	public  boolean relative(int rows) throws SQLException {
		if (Driver.trace) {
			Object[] args = { new Integer(rows)};
			Debug.methodCall(this, "relative", args);
		}
		if (_rows.size() == 0) {
			return false;
		}

		int new_row_position = _currentRow + rows + 1;

		boolean b = absolute(new_row_position);
		
		if (Driver.trace) {
			Debug.returnValue(this, "relative", new Boolean(b));
		}
		
		return b;
	}

	/**
	 * JDBC 2.0
	 *
	 * <p>Moves to the previous row in the result set.  
	 *
	 * <p>Note: previous() is not the same as relative(-1) since it
	 * makes sense to call previous() when there is no current row.
	 *
	 * @return true if on a valid row, false if off the result set.
	 * @exception SQLException if a database-access error occurs, or
	 * result set type is TYPE_FORWAR_DONLY.
	 */

	public boolean previous() throws SQLException {
		if (Driver.trace) {
			Object[] args = {
			};
			Debug.methodCall(this, "previous", args);
		}
		if (_on_insert_row) {
			_on_insert_row = false;
		}

		if (_doing_updates) {
			_doing_updates = false;
			
		}

		return prev();
	}

	protected int _fetch_direction = FETCH_FORWARD;

	/**
	 * JDBC 2.0
	 *
	 * Give a hint as to the direction in which the rows in this result set
	 * will be processed.  The initial value is determined by the statement
	 * that produced the result set.  The fetch direction may be changed
	 * at any time.
	 *
	 * @exception SQLException if a database-access error occurs, or
	 * the result set type is TYPE_FORWARD_ONLY and direction is not 
	 * FETCH_FORWARD.
	 *
	 * MM.MySQL actually ignores this, because it has the whole result
	 * set anyway, so the direction is immaterial.
	 */

	public  void setFetchDirection(int direction) throws SQLException {
		if (direction != FETCH_FORWARD && direction != FETCH_REVERSE) {
			throw new SQLException("Illegal value for fetch direction", "S1009");
		}
		else {
			_fetch_direction = direction;
		}
	}

	/**
	 * JDBC 2.0
	 *
	 * Return the fetch direction for this result set.
	 *
	 * @exception SQLException if a database-access error occurs 
	 */

	public  int getFetchDirection() throws SQLException {
		return _fetch_direction;
	}

	protected int _fetch_size = 0;

	/**
	 * JDBC 2.0
	 *
	 * Give the JDBC driver a hint as to the number of rows that should 
	 * be fetched from the database when more rows are needed for this result
	 * set.  If the fetch size specified is zero, then the JDBC driver 
	 * ignores the value, and is free to make its own best guess as to what
	 * the fetch size should be.  The default value is set by the statement 
	 * that creates the result set.  The fetch size may be changed at any 
	 * time.
	 *
	 * @param rows the number of rows to fetch
	 * @exception SQLException if a database-access error occurs, or the
	 * condition 0 <= rows <= this.getMaxRows() is not satisfied.
	 *
	 * Currently ignored by this driver.
	 */

	public  void setFetchSize(int rows) throws SQLException {
		if (rows < 0 /* || rows > getMaxRows()*/
			) {
			throw new SQLException("Value must be between 0 and getMaxRows()", "S1009");
		}

		_fetch_size = rows;
	}

	/**
	 * JDBC 2.0
	 *
	 * Return the fetch size for this result set.
	 *
	 * @exception SQLException if a database-access error occurs 
	 */

	public  int getFetchSize() throws SQLException {
		return _fetch_size;
	}

	/**
	 * JDBC 2.0
	 *
	 * Return the type of this result set.  The type is determined based
	 * on the statement that created the result set.
	 *
	 * @return TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, or
	 * TYPE_SCROLL_SENSITIVE
	 * @exception SQLException if a database-access error occurs
	 */

	public int getType() throws SQLException {
		return _resultSetType;
	}

	/**
	 * JDBC 2.0
	 *
	 * Return the concurrency of this result set.  The concurrency
	 * used is determined by the statement that created the result set.
	 *
	 * @return the concurrency type, CONCUR_READ_ONLY, etc.
	 * @exception SQLException if a database-access error occurs
	 */

	public int getConcurrency() throws SQLException {
		return (_updatable ? CONCUR_UPDATABLE : CONCUR_READ_ONLY);
	}

	//---------------------------------------------------------------------
	// Updates
	//---------------------------------------------------------------------

	/**
	 * JDBC 2.0
	 *
	 * Determine if the current row has been updated.  The value returned 
	 * depends on whether or not the result set can detect updates.
	 *
	 * @return true if the row has been visibly updated by the owner or
	 * another, and updates are detected
	 * @exception SQLException if a database-access error occurs
	 * 
	 * @see DatabaseMetaData#updatesAreDetected
	 */

	public  boolean rowUpdated() throws SQLException {
		throw new NotImplemented();
	}

	/**
	 * JDBC 2.0
	 *
	 * Determine if the current row has been inserted.  The value returned 
	 * depends on whether or not the result set can detect visible inserts.
	 *
	 * @return true if inserted and inserts are detected
	 * @exception SQLException if a database-access error occurs
	 * 
	 * @see DatabaseMetaData#insertsAreDetected
	 */

	public  boolean rowInserted() throws SQLException {
		throw new NotImplemented();
	}

	/**
	 * JDBC 2.0
	 *
	 * Determine if this row has been deleted.  A deleted row may leave
	 * a visible "hole" in a result set.  This method can be used to
	 * detect holes in a result set.  The value returned depends on whether 
	 * or not the result set can detect deletions.
	 *
	 * @return true if deleted and deletes are detected
	 * @exception SQLException if a database-access error occurs
	 * 
	 * @see DatabaseMetaData#deletesAreDetected
	 */

	public  boolean rowDeleted() throws SQLException {
		throw new NotImplemented();
	}

	/**
	 * JDBC 2.0
	 * 
	 * Give a nullable column a null value.
	 * 
	 * The updateXXX() methods are used to update column values in the
	 * current row, or the insert row.  The updateXXX() methods do not 
	 * update the underlying database, instead the updateRow() or insertRow()
	 * methods are called to update the database.
	 *
	 * @param columnIndex the first column is 1, the second is 2, ...
	 * @exception SQLException if a database-access error occurs
	 */

	public  void updateNull(int columnIndex) throws SQLException {
		if (!_on_insert_row) {
			if (!_doing_updates) {
				_doing_updates = true;

				syncUpdate();
			}

			_Updater.setNull(columnIndex, 0);
		}
		else {
			_Inserter.setNull(columnIndex, 0);
		}
	}

	/**
	 * JDBC 2.0
	 * 
	 * Update a column with a boolean value.
	 *
	 * The updateXXX() methods are used to update column values in the
	 * current row, or the insert row.  The updateXXX() methods do not 
	 * update the underlying database, instead the updateRow() or insertRow()
	 * methods are called to update the database.
	 *
	 * @param columnIndex the first column is 1, the second is 2, ...
	 * @param x the new column value
	 * @exception SQLException if a database-access error occurs
	 */

	public  void updateBoolean(int columnIndex, boolean x) throws SQLException {
		if (!_on_insert_row) {
			if (!_doing_updates) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -