7047 lines · 303.9 KB · Java
RawDownload
     * as a stream of uninterpreted bytes;     * if the value is SQL <code>NULL</code>, the result is <code>null</code>     * @throws SQLException if (1) a database access error occurs     *            or (2) this rowset does not have a currently valid connection,     *            prepared statement, and result set     */    public java.io.InputStream getBinaryStream(String columnName) throws SQLException {        return getBinaryStream(findColumn(columnName));    }      //=====================================================================    // Advanced features:    //=====================================================================     /**     * Returns the first warning reported by calls on this rowset's     * <code>ResultSet</code> object.     * Subsequent warnings on this rowset's <code>ResultSet</code> object     * will be chained to the <code>SQLWarning</code> object that     * this method returns.     *     * <P>The warning chain is automatically cleared each time a new     * row is read.     *     * <P><B>Note:</B> This warning chain only covers warnings caused     * by <code>ResultSet</code> methods.  Any warning caused by     * <code>Statement</code> methods     * (such as reading OUT parameters) will be chained on the     * <code>Statement</code> object.     *     * @return the first <code>SQLWarning</code> object reported or <code>null</code>     * @throws SQLException if (1) a database access error occurs     *            or (2) this rowset does not have a currently valid connection,     *            prepared statement, and result set     */    public SQLWarning getWarnings() throws SQLException {        checkState();         return rs.getWarnings();    }     /**     * Clears all warnings reported on this rowset's <code>ResultSet</code> object.     * After this method is called, the method <code>getWarnings</code>     * returns <code>null</code> until a new warning is     * reported for this rowset's <code>ResultSet</code> object.     *     * @throws SQLException if (1) a database access error occurs     *            or (2) this rowset does not have a currently valid connection,     *            prepared statement, and result set     */    public void clearWarnings() throws SQLException {        checkState();         rs.clearWarnings();    }     /**     * Gets the name of the SQL cursor used by this rowset's <code>ResultSet</code>     * object.     *     * <P>In SQL, a result table is retrieved through a cursor that is     * named. The current row of a result set can be updated or deleted     * using a positioned update/delete statement that references the     * cursor name. To insure that the cursor has the proper isolation     * level to support update, the cursor's <code>select</code> statement should be     * of the form 'select for update'. If the 'for update' clause is     * omitted, the positioned updates may fail.     *     * <P>The JDBC API supports this SQL feature by providing the name of the     * SQL cursor used by a <code>ResultSet</code> object.     * The current row of a <code>ResultSet</code> object     * is also the current row of this SQL cursor.     *     * <P><B>Note:</B> If positioned update is not supported, a     * <code>SQLException</code> is thrown.     *     * @return the SQL name for this rowset's <code>ResultSet</code> object's cursor     * @throws SQLException if (1) a database access error occurs     *            or (2) xthis rowset does not have a currently valid connection,     *            prepared statement, and result set     */    public String getCursorName() throws SQLException {        checkState();         return rs.getCursorName();    }     /**     * Retrieves the  number, types and properties of     * this rowset's <code>ResultSet</code> object's columns.     *     * @return the description of this rowset's <code>ResultSet</code>     *     object's columns     * @throws SQLException if (1) a database access error occurs     *     or (2) this rowset does not have a currently valid connection,     *     prepared statement, and result set     */    public ResultSetMetaData getMetaData() throws SQLException {         checkState();         // It may be the case that JdbcRowSet might not have been        // initialized with ResultSet handle and may be by PreparedStatement        // internally when we set JdbcRowSet.setCommand().        // We may require all the basic properties of setEscapeProcessing        // setMaxFieldSize etc. which an application can use before we call        // execute.        try {             checkState();        } catch(SQLException sqle) {             prepare();             // will return ResultSetMetaData             return ps.getMetaData();        }        return rs.getMetaData();    }     /**     * <p>Gets the value of the designated column in the current row     * of this rowset's <code>ResultSet</code> object as     * an <code>Object</code>.     *     * <p>This method will return the value of the given column as a     * Java object.  The type of the Java object will be the default     * Java object type corresponding to the column's SQL type,     * following the mapping for built-in types specified in the JDBC     * specification.     *     * <p>This method may also be used to read datatabase-specific     * abstract data types.     *     * In the JDBC 3.0 API, the behavior of method     * <code>getObject</code> is extended to materialize     * data of SQL user-defined types.  When a column contains     * a structured or distinct value, the behavior of this method is as     * if it were a call to: <code>getObject(columnIndex,     * this.getStatement().getConnection().getTypeMap())</code>.     *     * @param columnIndex the first column is 1, the second is 2, and so on     * @return a <code>java.lang.Object</code> holding the column value     * @throws SQLException if (1) a database access error occurs     *            or (2) this rowset does not currently have a valid connection,     *            prepared statement, and result set     */    public Object getObject(int columnIndex) throws SQLException {        checkState();         return rs.getObject(columnIndex);    }     /**     * <p>Gets the value of the designated column in the current row     * of this rowset's <code>ResultSet</code> object as     * an <code>Object</code>.     *     * <p>This method will return the value of the given column as a     * Java object.  The type of the Java object will be the default     * Java object type corresponding to the column's SQL type,     * following the mapping for built-in types specified in the JDBC     * specification.     *     * <p>This method may also be used to read datatabase-specific     * abstract data types.     *     * In the JDBC 3.0 API, the behavior of the method     * <code>getObject</code> is extended to materialize     * data of SQL user-defined types.  When a column contains     * a structured or distinct value, the behavior of this method is as     * if it were a call to: <code>getObject(columnIndex,     * this.getStatement().getConnection().getTypeMap())</code>.     *     * @param columnName the SQL name of the column     * @return a <code>java.lang.Object</code> holding the column value     * @throws SQLException if (1) a database access error occurs     *            or (2) this rowset does not currently have a valid connection,     *            prepared statement, and result set     */    public Object getObject(String columnName) throws SQLException {        return getObject(findColumn(columnName));    }     //----------------------------------------------------------------     /**     * Maps the given <code>JdbcRowSetImpl</code> column name to its     * <code>JdbcRowSetImpl</code> column index and reflects this on     * the internal <code>ResultSet</code> object.     *     * @param columnName the name of the column     * @return the column index of the given column name     * @throws SQLException if (1) a database access error occurs     * (2) this rowset does not have a currently valid connection,     * prepared statement, and result set     */    public int findColumn(String columnName) throws SQLException {        checkState();         return rs.findColumn(columnName);    }      //--------------------------JDBC 2.0-----------------------------------     //---------------------------------------------------------------------    // Getters and Setters    //---------------------------------------------------------------------     /**     * Gets the value of the designated column in the current row     * of this rowset's <code>ResultSet</code> object as a     * <code>java.io.Reader</code> object.     * @return a <code>java.io.Reader</code> object that contains the column     * value; if the value is SQL <code>NULL</code>, the value returned is     * <code>null</code>.     * @param columnIndex the first column is 1, the second is 2, and so on     *     */    public java.io.Reader getCharacterStream(int columnIndex) throws SQLException {        checkState();         return rs.getCharacterStream(columnIndex);    }     /**     * Gets the value of the designated column in the current row     * of this rowset's <code>ResultSet</code> object as a     * <code>java.io.Reader</code> object.     *     * @return a <code>java.io.Reader</code> object that contains the column     * value; if the value is SQL <code>NULL</code>, the value returned is     * <code>null</code>.     * @param columnName the name of the column     * @return the value in the specified column as a <code>java.io.Reader</code>     *     */    public java.io.Reader getCharacterStream(String columnName) throws SQLException {        return getCharacterStream(findColumn(columnName));    }     /**     * Gets the value of the designated column in the current row     * of this rowset's <code>ResultSet</code> object as a     * <code>java.math.BigDecimal</code> with full precision.     *     * @param columnIndex the first column is 1, the second is 2, and so on     * @return the column value (full precision);     * if the value is SQL <code>NULL</code>, the value returned is     * <code>null</code>.     * @throws SQLException if a database access error occurs     *            or this rowset does not currently have a valid     *            connection, prepared statement, and result set     */    public BigDecimal getBigDecimal(int columnIndex) throws SQLException {        checkState();         return rs.getBigDecimal(columnIndex);    }     /**     * Gets the value of the designated column in the current row     * of this rowset's <code>ResultSet</code> object as a     * <code>java.math.BigDecimal</code> with full precision.     *     * @param columnName the column name     * @return the column value (full precision);     * if the value is SQL <code>NULL</code>, the value returned is     * <code>null</code>.     * @throws SQLException if a database access error occurs     *            or this rowset does not currently have a valid     *            connection, prepared statement, and result set     */    public BigDecimal getBigDecimal(String columnName) throws SQLException {        return getBigDecimal(findColumn(columnName));    }     //---------------------------------------------------------------------    // Traversal/Positioning    //---------------------------------------------------------------------     /**     * Indicates whether the cursor is before the first row in     * this rowset's <code>ResultSet</code> object.     *     * @return <code>true</code> if the cursor is before the first row;     * <code>false</code> if the cursor is at any other position or the     * result set contains no rows     * @throws SQLException if a database access error occurs     *            or this rowset does not currently have a valid     *            connection, prepared statement, and result set     */    public boolean isBeforeFirst() throws SQLException {        checkState();         return rs.isBeforeFirst();    }     /**     * Indicates whether the cursor is after the last row in     * this rowset's <code>ResultSet</code> object.     *     * @return <code>true</code> if the cursor is after the last row;     * <code>false</code> if the cursor is at any other position or the     * result set contains no rows     * @throws SQLException if a database access error occurs     *            or this rowset does not currently have a valid     *            connection, prepared statement, and result set     */    public boolean isAfterLast() throws SQLException {        checkState();         return rs.isAfterLast();    }     /**     * Indicates whether the cursor is on the first row of     * this rowset's <code>ResultSet</code> object.     *     * @return <code>true</code> if the cursor is on the first row;     * <code>false</code> otherwise     * @throws SQLException if a database access error occurs     *            or this rowset does not currently have a valid     *            connection, prepared statement, and result set     */    public boolean isFirst() throws SQLException {        checkState();         return rs.isFirst();    }     /**     * Indicates whether the cursor is on the last row of     * this rowset's <code>ResultSet</code> object.     * Note: Calling the method <code>isLast</code> may be expensive     * because 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 <code>true</code> if the cursor is on the last row;     * <code>false</code> otherwise     * @throws SQLException if a database access error occurs     *            or this rowset does not currently have a valid     *            connection, prepared statement, and result set     *     */    public boolean isLast() throws SQLException {        checkState();         return rs.isLast();    }     /**     * Moves the cursor to the front of     * this rowset's <code>ResultSet</code> object, just before the     * first row. This method has no effect if the result set contains no rows.     *     * @throws SQLException if (1) a database access error occurs,     *            (2) the result set type is <code>TYPE_FORWARD_ONLY</code>,     *            or (3) this rowset does not currently have a valid     *            connection, prepared statement, and result set     */    public void beforeFirst() throws SQLException {        checkState();         rs.beforeFirst();        notifyCursorMoved();    }     /**     * Moves the cursor to the end of     * this rowset's <code>ResultSet</code> object, just after the     * last row. This method has no effect if the result set contains no rows.     * @throws SQLException if (1) a database access error occurs,     *            (2) the result set type is <code>TYPE_FORWARD_ONLY</code>,     *            or (3) this rowset does not currently have a valid     *            connection, prepared statement, and result set     */    public void afterLast() throws SQLException {        checkState();         rs.afterLast();        notifyCursorMoved();    }     /**     * Moves the cursor to the first row in     * this rowset's <code>ResultSet</code> object.     *     * @return <code>true</code> if the cursor is on a valid row;     * <code>false</code> if there are no rows in the result set     * @throws SQLException if (1) a database access error occurs,     *            (2) the result set type is <code>TYPE_FORWARD_ONLY</code>,     *            or (3) this rowset does not currently have a valid     *            connection, prepared statement, and result set     */    public boolean first() throws SQLException {        checkState();         boolean b = rs.first();        notifyCursorMoved();        return b;     }     /**     * Moves the cursor to the last row in     * this rowset's <code>ResultSet</code> object.     *     * @return <code>true</code> if the cursor is on a valid row;     * <code>false</code> if there are no rows in the result set     * @throws SQLException if (1) a database access error occurs,     *            (2) the result set type is <code>TYPE_FORWARD_ONLY</code>,     *            or (3) this rowset does not currently have a valid     *            connection, prepared statement, and result set     */    public boolean last() throws SQLException {        checkState();         boolean b = rs.last();        notifyCursorMoved();        return b;    }     /**     * Retrieves the current row number.  The first row is number 1, the     * second is number 2, and so on.     *     * @return the current row number; <code>0</code> if there is no current row     * @throws SQLException if a database access error occurs     *            or this rowset does not currently have a valid connection,     *            prepared statement, and result set     */    public int getRow() throws SQLException {        checkState();         return rs.getRow();    }     /**     * Moves the cursor to the given row number in     * this rowset's internal <code>ResultSet</code> object.     *     * <p>If the row number is positive, the cursor moves to     * the given row number with respect to the     * beginning of the result set.  The first row is row 1, the second     * is row 2, and so on.     *     * <p>If the given row number is negative, the cursor moves to     * an absolute row position with respect to     * the end of the result set.  For example, calling the method     * <code>absolute(-1)</code> positions the     * cursor on the last row, calling the method <code>absolute(-2)</code>     * moves the cursor to the next-to-last row, and so on.     *     * <p>An attempt to position the cursor beyond the first/last row in     * the result set leaves the cursor before the first row or after     * the last row.     *     * <p><B>Note:</B> Calling <code>absolute(1)</code> is the same     * as calling <code>first()</code>. Calling <code>absolute(-1)</code>     * is the same as calling <code>last()</code>.     *     * @return <code>true</code> if the cursor is on the result set;     * <code>false</code> otherwise     * @throws SQLException if (1) a database access error occurs,     *            (2) the row is <code>0</code>, (3) the result set     *            type is <code>TYPE_FORWARD_ONLY</code>, or (4) this     *            rowset does not currently have a valid connection,     *            prepared statement, and result set     */    public boolean absolute(int row) throws SQLException {        checkState();         boolean b = rs.absolute(row);        notifyCursorMoved();        return b;    }     /**     * Moves the cursor 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 <code>relative(0)</code> is valid, but does     * not change the cursor position.     *     * <p>Note: Calling the method <code>relative(1)</code>     * is different from calling the method <code>next()</code>     * because is makes sense to call <code>next()</code> 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 <code>true</code> if the cursor is on a row;     * <code>false</code> otherwise     * @throws SQLException if (1) a database access error occurs,     *            (2) there is no current row, (3) the result set     *            type is <code>TYPE_FORWARD_ONLY</code>, or (4) this     *            rowset does not currently have a valid connection,     *            prepared statement, and result set

Lines 1501–2000 of 7047. Previous lines