📄 embedresultset.java
字号:
public final Statement getStatement() { return applicationStmt; } /** * Set the application Statement object that created this ResultSet. * Used when the Statement objects returned to the application * are wrapped for XA. */ public final void setApplicationStatement(Statement applicationStmt) { this.applicationStmt = applicationStmt; } //--------------------------------------------------------------------- // Traversal/Positioning //--------------------------------------------------------------------- /** * JDBC 2.0 * * <p> * Determine if the cursor is before the first row in the result set. * * @return true if before the first row, false otherwise. Returns false when * the result set contains no rows. * @exception SQLException * Thrown on error. */ public boolean isBeforeFirst() throws SQLException { return checkRowPosition(ResultSet.ISBEFOREFIRST, "isBeforeFirst"); } /** * JDBC 2.0 * * <p> * Determine if the cursor is after the last row in the result set. * * @return true if after the last row, false otherwise. Returns false when * the result set contains no rows. * @exception SQLException * Thrown on error. */ public boolean isAfterLast() throws SQLException { return checkRowPosition(ResultSet.ISAFTERLAST, "isAfterLast"); } /** * JDBC 2.0 * * <p> * Determine if the cursor is on the first row of the result set. * * @return true if on the first row, false otherwise. * @exception SQLException * Thrown on error. */ public boolean isFirst() throws SQLException { return checkRowPosition(ResultSet.ISFIRST, "isFirst"); } /** * JDBC 2.0 * * <p> * Determine if the cursor is on the last row of the result set. Note: * Calling isLast() may be expensive since the JDBC driver might need to * fetch ahead one row in order to determine whether the current row is the * last row in the result set. * * @return true if on the last row, false otherwise. * @exception SQLException * Thrown on error. */ public boolean isLast() throws SQLException { return checkRowPosition(ResultSet.ISLAST, "isLast"); } /** * JDBC 2.0 * * <p> * Moves to the front of the result set, just before the first row. Has no * effect if the result set contains no rows. * * @exception SQLException * if a database-access error occurs, or result set type is * TYPE_FORWARD_ONLY */ public void beforeFirst() throws SQLException { // beforeFirst is only allowed on scroll cursors checkScrollCursor("beforeFirst()"); movePosition(BEFOREFIRST, "beforeFirst"); } /** * JDBC 2.0 * * <p> * Moves to the end of the result set, just after the last row. Has no * effect if the result set contains no rows. * * @exception SQLException * if a database-access error occurs, or result set type is * TYPE_FORWARD_ONLY. */ public void afterLast() throws SQLException { // afterLast is only allowed on scroll cursors checkScrollCursor("afterLast()"); movePosition(AFTERLAST, "afterLast"); } /** * 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 { // first is only allowed on scroll cursors checkScrollCursor("first()"); return movePosition(FIRST, "first"); } /** * 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 { // last is only allowed on scroll cursors checkScrollCursor("last()"); return movePosition(LAST, "last"); } /** * 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 { // getRow() is only allowed on scroll cursors checkScrollCursor("getRow()"); /* * * We probably needn't bother getting the text of * the underlying * statement but it is better to be * consistent and we aren't * particularly worried * about performance of getRow(). */ return theResults.getRowNumber(); } /** * 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 { // absolute is only allowed on scroll cursors checkScrollCursor("absolute()"); return movePosition(ABSOLUTE, row, "absolute"); } /** * 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 row) throws SQLException { // absolute is only allowed on scroll cursors checkScrollCursor("relative()"); return movePosition(RELATIVE, row, "relative"); } /** * 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 { // previous is only allowed on scroll cursors checkScrollCursor("previous()"); return movePosition(PREVIOUS, "previous"); } //--------------------------------------------------------------------- // Properties //--------------------------------------------------------------------- /** * 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. */ public void setFetchDirection(int direction) throws SQLException { checkScrollCursor("setFetchDirection()"); /* * FetchDirection is meaningless to us. We just save it off and return * the current value if asked. */ fetchDirection = 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 { if (fetchDirection == 0) { // value is not set at the result set level // get it from the statement level return stmt.getFetchDirection(); } else return fetchDirection; } /** * 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. */ public void setFetchSize(int rows) throws SQLException { if (rows < 0 || (stmt.getMaxRows() != 0 && rows > stmt.getMaxRows())) { throw Util.generateCsSQLException(SQLState.INVALID_FETCH_SIZE, new Integer(rows)); } else if (rows > 0) // if it is zero ignore the call { fetchSize = 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 { if (fetchSize == 0) { // value is not set at the result set level // get the default value from the statement return stmt.getFetchSize(); } else return fetchSize; } /** * 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 stmt.getResultSetType(); } /** * JDBC 2.0 * * Return the concurrency of this result set. The concurrency is determined * as follows If Statement object has CONCUR_READ_ONLY concurrency, then * ResultSet object will also have the CONCUR_READ_ONLY concurrency. But if * Statement object has CONCUR_UPDATABLE concurrency, then the concurrency * of ResultSet object depends on whether the underlying language resultset * is updatable or not. If the language resultset is updatable, then JDBC * ResultSet object will also have the CONCUR_UPDATABLE concurrency. If * lanugage resultset is not updatable, then JDBC ResultSet object * concurrency will be set to CONCUR_READ_ONLY. * * @return the concurrency type, CONCUR_READ_ONLY, etc. * @exception SQLException * if a database-access error occurs */ public int getConcurrency() throws SQLException { return concurrencyOfThisResultSet; } //--------------------------------------------------------------------- // 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 EmbedDatabaseMetaData#updatesAreDetected */ public boolean rowUpdated() throws SQLException { return false; } /** * 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 EmbedDatabaseMetaData#insertsAreDetected */ public boolean rowInserted() throws SQLException { throw Util.notImpl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -