10133 lines · 431.3 KB · Java
RawDownload
        checkIndex(columnIndex);        // make sure the cursor is on a valid row        checkCursor();         Object obj = convertNumeric(x,        java.sql.Types.NUMERIC,        RowSetMD.getColumnType(columnIndex));         getCurrentRow().setColumnObject(columnIndex, obj);    }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * <code>String</code> object.     * <P>     * This method updates a column value in either the current row or     * the insert row of this rowset, but it does not update the     * database.  If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to mark the row as updated.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called to insert the new row into this rowset and mark it     * as inserted. Both of these methods must be called before the     * cursor moves to another row.     * <P>     * The method <code>acceptChanges</code> must be called if the     * updated values are to be written back to the underlying database.     *     * @param columnIndex the first column is <code>1</code>, the second     *        is <code>2</code>, and so on; must be <code>1</code> or larger     *        and equal to or less than the number of columns in this rowset     * @param x the new column value     * @throws SQLException if (1) the given column index is out of bounds,     *            (2) the cursor is not on one of this rowset's rows or its     *            insert row, or (3) this rowset is     *            <code>ResultSet.CONCUR_READ_ONLY</code>     */    public void updateString(int columnIndex, String x) throws SQLException {        // sanity check.        checkIndex(columnIndex);        // make sure the cursor is on a valid row        checkCursor();         getCurrentRow().setColumnObject(columnIndex, x);    }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * <code>byte</code> array.     *     * This method updates a column value in either the current row or     * the insert row of this rowset, but it does not update the     * database.  If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to update the database.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called, which will insert the new row into both this rowset     * and the database. Both of these methods must be called before the     * cursor moves to another row.     *     * @param columnIndex the first column is <code>1</code>, the second     *        is <code>2</code>, and so on; must be <code>1</code> or larger     *        and equal to or less than the number of columns in this rowset     * @param x the new column value     * @throws SQLException if (1) the given column index is out of bounds,     *            (2) the cursor is not on one of this rowset's rows or its     *            insert row, or (3) this rowset is     *            <code>ResultSet.CONCUR_READ_ONLY</code>     */    public void updateBytes(int columnIndex, byte x[]) throws SQLException {        // sanity check.        checkIndex(columnIndex);        // make sure the cursor is on a valid row        checkCursor();         if (isBinary(RowSetMD.getColumnType(columnIndex)) == false) {            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());        }         getCurrentRow().setColumnObject(columnIndex, x);    }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * <code>Date</code> object.     *     * This method updates a column value in either the current row or     * the insert row of this rowset, but it does not update the     * database.  If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to update the database.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called, which will insert the new row into both this rowset     * and the database. Both of these methods must be called before the     * cursor moves to another row.     *     * @param columnIndex the first column is <code>1</code>, the second     *        is <code>2</code>, and so on; must be <code>1</code> or larger     *        and equal to or less than the number of columns in this rowset     * @param x the new column value     * @throws SQLException if (1) the given column index is out of bounds,     *            (2) the cursor is not on one of this rowset's rows or its     *            insert row, (3) the type of the designated column is not     *            an SQL <code>DATE</code> or <code>TIMESTAMP</code>, or     *            (4) this rowset is <code>ResultSet.CONCUR_READ_ONLY</code>     */    public void updateDate(int columnIndex, java.sql.Date x) throws SQLException {        // sanity check.        checkIndex(columnIndex);        // make sure the cursor is on a valid row        checkCursor();         Object obj = convertTemporal(x,        java.sql.Types.DATE,        RowSetMD.getColumnType(columnIndex));         getCurrentRow().setColumnObject(columnIndex, obj);    }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * <code>Time</code> object.     *     * This method updates a column value in either the current row or     * the insert row of this rowset, but it does not update the     * database.  If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to update the database.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called, which will insert the new row into both this rowset     * and the database. Both of these methods must be called before the     * cursor moves to another row.     *     * @param columnIndex the first column is <code>1</code>, the second     *        is <code>2</code>, and so on; must be <code>1</code> or larger     *        and equal to or less than the number of columns in this rowset     * @param x the new column value     * @throws SQLException if (1) the given column index is out of bounds,     *            (2) the cursor is not on one of this rowset's rows or its     *            insert row, (3) the type of the designated column is not     *            an SQL <code>TIME</code> or <code>TIMESTAMP</code>, or     *            (4) this rowset is <code>ResultSet.CONCUR_READ_ONLY</code>     */    public void updateTime(int columnIndex, java.sql.Time x) throws SQLException {        // sanity check.        checkIndex(columnIndex);        // make sure the cursor is on a valid row        checkCursor();         Object obj = convertTemporal(x,        java.sql.Types.TIME,        RowSetMD.getColumnType(columnIndex));         getCurrentRow().setColumnObject(columnIndex, obj);    }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * <code>Timestamp</code> object.     *     * This method updates a column value in either the current row or     * the insert row of this rowset, but it does not update the     * database.  If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to update the database.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called, which will insert the new row into both this rowset     * and the database. Both of these methods must be called before the     * cursor moves to another row.     *     * @param columnIndex the first column is <code>1</code>, the second     *        is <code>2</code>, and so on; must be <code>1</code> or larger     *        and equal to or less than the number of columns in this rowset     * @param x the new column value     * @throws SQLException if (1) the given column index is out of bounds,     *            (2) the cursor is not on one of this rowset's rows or its     *            insert row, (3) the type of the designated column is not     *            an SQL <code>DATE</code>, <code>TIME</code>, or     *            <code>TIMESTAMP</code>, or (4) this rowset is     *            <code>ResultSet.CONCUR_READ_ONLY</code>     */    public void updateTimestamp(int columnIndex, java.sql.Timestamp x) throws SQLException {        // sanity check.        checkIndex(columnIndex);        // make sure the cursor is on a valid row        checkCursor();         Object obj = convertTemporal(x,        java.sql.Types.TIMESTAMP,        RowSetMD.getColumnType(columnIndex));         getCurrentRow().setColumnObject(columnIndex, obj);    }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * ASCII stream value.     * <P>     * This method updates a column value in either the current row or     * the insert row of this rowset, but it does not update the     * database.  If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to update the database.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called, which will insert the new row into both this rowset     * and the database. Both of these methods must be called before the     * cursor moves to another row.     *     * @param columnIndex the first column is <code>1</code>, the second     *        is <code>2</code>, and so on; must be <code>1</code> or larger     *        and equal to or less than the number of columns in this rowset     * @param x the new column value     * @param length the number of one-byte ASCII characters in the stream     * @throws SQLException if this method is invoked     */    public void updateAsciiStream(int columnIndex, java.io.InputStream x, int length) throws SQLException {        // sanity Check        checkIndex(columnIndex);        // make sure the cursor is on a valid row        checkCursor();          if (isString(RowSetMD.getColumnType(columnIndex)) == false &&        isBinary(RowSetMD.getColumnType(columnIndex)) == false) {            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());        }         byte buf[] = new byte[length];        try {            int charsRead = 0;            do {                charsRead += x.read(buf, charsRead, length - charsRead);            } while (charsRead != length);            //Changed the condition check to check for length instead of -1        } catch (java.io.IOException ex) {            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.asciistream").toString());        }        String str = new String(buf);         getCurrentRow().setColumnObject(columnIndex, str);     }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * <code>java.io.InputStream</code> object.     * <P>     * This method updates a column value in either the current row or     * the insert row of this rowset, but it does not update the     * database.  If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to update the database.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called, which will insert the new row into both this rowset     * and the database. Both of these methods must be called before the     * cursor moves to another row.     *     * @param columnIndex the first column is <code>1</code>, the second     *        is <code>2</code>, and so on; must be <code>1</code> or larger     *        and equal to or less than the number of columns in this rowset     * @param x the new column value; must be a <code>java.io.InputStream</code>     *          containing <code>BINARY</code>, <code>VARBINARY</code>, or     *          <code>LONGVARBINARY</code> data     * @param length the length of the stream in bytes     * @throws SQLException if (1) the given column index is out of bounds,     *            (2) the cursor is not on one of this rowset's rows or its     *            insert row, (3) the data in the stream is not binary, or     *            (4) this rowset is <code>ResultSet.CONCUR_READ_ONLY</code>     */    public void updateBinaryStream(int columnIndex, java.io.InputStream x,int length) throws SQLException {        // sanity Check        checkIndex(columnIndex);        // make sure the cursor is on a valid row        checkCursor();         if (isBinary(RowSetMD.getColumnType(columnIndex)) == false) {            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());        }         byte buf[] = new byte[length];        try {            int bytesRead = 0;            do {                bytesRead += x.read(buf, bytesRead, length - bytesRead);            } while (bytesRead != -1);        } catch (java.io.IOException ex) {            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.binstream").toString());        }         getCurrentRow().setColumnObject(columnIndex, buf);    }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * <code>java.io.Reader</code> object.     * <P>     * This method updates a column value in either the current row or     * the insert row of this rowset, but it does not update the     * database.  If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to update the database.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called, which will insert the new row into both this rowset     * and the database. Both of these methods must be called before the     * cursor moves to another row.     *     * @param columnIndex the first column is <code>1</code>, the second     *        is <code>2</code>, and so on; must be <code>1</code> or larger     *        and equal to or less than the number of columns in this rowset     * @param x the new column value; must be a <code>java.io.Reader</code>     *          containing <code>BINARY</code>, <code>VARBINARY</code>,     *          <code>LONGVARBINARY</code>, <code>CHAR</code>, <code>VARCHAR</code>,     *          or <code>LONGVARCHAR</code> data     * @param length the length of the stream in characters     * @throws SQLException if (1) the given column index is out of bounds,     *            (2) the cursor is not on one of this rowset's rows or its     *            insert row, (3) the data in the stream is not a binary or     *            character type, or (4) this rowset is     *            <code>ResultSet.CONCUR_READ_ONLY</code>     */    public void updateCharacterStream(int columnIndex, java.io.Reader x, int length) throws SQLException {        // sanity Check        checkIndex(columnIndex);        // make sure the cursor is on a valid row        checkCursor();         if (isString(RowSetMD.getColumnType(columnIndex)) == false &&        isBinary(RowSetMD.getColumnType(columnIndex)) == false) {            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());        }         char buf[] = new char[length];        try {            int charsRead = 0;            do {                charsRead += x.read(buf, charsRead, length - charsRead);            } while (charsRead != length);            //Changed the condition checking to check for length instead of -1        } catch (java.io.IOException ex) {            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.binstream").toString());        }        String str = new String(buf);         getCurrentRow().setColumnObject(columnIndex, str);    }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * <code>Object</code> value.  The <code>scale</code> parameter indicates     * the number of digits to the right of the decimal point and is ignored     * if the new column value is not a type that will be mapped to an SQL     * <code>DECIMAL</code> or <code>NUMERIC</code> value.     * <P>     * This method updates a column value in either the current row or     * the insert row of this rowset, but it does not update the     * database.  If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to update the database.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called, which will insert the new row into both this rowset     * and the database. Both of these methods must be called before the     * cursor moves to another row.     *     * @param columnIndex the first column is <code>1</code>, the second     *        is <code>2</code>, and so on; must be <code>1</code> or larger     *        and equal to or less than the number of columns in this rowset     * @param x the new column value     * @param scale the number of digits to the right of the decimal point (for     *              <code>DECIMAL</code> and <code>NUMERIC</code> types only)     * @throws SQLException if (1) the given column index is out of bounds,     *            (2) the cursor is not on one of this rowset's rows or its     *            insert row, or (3) this rowset is     *            <code>ResultSet.CONCUR_READ_ONLY</code>     */    public void updateObject(int columnIndex, Object x, int scale) throws SQLException {        // sanity check.        checkIndex(columnIndex);        // make sure the cursor is on a valid row        checkCursor();         int type = RowSetMD.getColumnType(columnIndex);        if (type == Types.DECIMAL || type == Types.NUMERIC) {            ((java.math.BigDecimal)x).setScale(scale);        }        getCurrentRow().setColumnObject(columnIndex, x);    }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * <code>Object</code> value.     * <P>     * This method updates a column value in either the current row or     * the insert row of this rowset, but it does not update the     * database.  If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to update the database.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called, which will insert the new row into both this rowset     * and the database. Both of these methods must be called before the     * cursor moves to another row.     *     * @param columnIndex the first column is <code>1</code>, the second     *        is <code>2</code>, and so on; must be <code>1</code> or larger     *        and equal to or less than the number of columns in this rowset     * @param x the new column value     * @throws SQLException if (1) the given column index is out of bounds,     *            (2) the cursor is not on one of this rowset's rows or its     *            insert row, or (3) this rowset is     *            <code>ResultSet.CONCUR_READ_ONLY</code>     */    public void updateObject(int columnIndex, Object x) throws SQLException {        // sanity check.        checkIndex(columnIndex);        // make sure the cursor is on a valid row        checkCursor();         getCurrentRow().setColumnObject(columnIndex, x);    }     /**     * Sets the designated nullable column in the current row or the     * insert row of this <code>CachedRowSetImpl</code> object with     * <code>null</code> value.     * <P>     * This method updates a column value in the current row or the insert     * row of this rowset, but it does not update the database.     * If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to update the database.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called, which will insert the new row into both this rowset     * and the database.     *     * @param columnName a <code>String</code> object that must match the     *        SQL name of a column in this rowset, ignoring case     * @throws SQLException if (1) the given column name does not match the     *            name of a column in this rowset, (2) the cursor is not on     *            one of this rowset's rows or its insert row, or (3) this     *            rowset is <code>ResultSet.CONCUR_READ_ONLY</code>     */    public void updateNull(String columnName) throws SQLException {        updateNull(getColIdxByName(columnName));    }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * <code>boolean</code> value.     * <P>     * This method updates a column value in the current row or the insert     * row of this rowset, but it does not update the database.     * If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to update the database.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called, which will insert the new row into both this rowset     * and the database. Both of these methods must be called before the     * cursor moves to another row.     *     * @param columnName a <code>String</code> object that must match the     *        SQL name of a column in this rowset, ignoring case     * @param x the new column value     * @throws SQLException if (1) the given column name does not match the     *            name of a column in this rowset, (2) the cursor is not on     *            one of this rowset's rows or its insert row, or (3) this     *            rowset is <code>ResultSet.CONCUR_READ_ONLY</code>     */    public void updateBoolean(String columnName, boolean x) throws SQLException {        updateBoolean(getColIdxByName(columnName), x);    }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * <code>byte</code> value.     * <P>     * This method updates a column value in the current row or the insert     * row of this rowset, but it does not update the database.     * If the cursor is on a row in the rowset, the     * method {@link #updateRow} must be called to update the database.     * If the cursor is on the insert row, the method {@link #insertRow}     * must be called, which will insert the new row into both this rowset     * and the database. Both of these methods must be called before the     * cursor moves to another row.     *     * @param columnName a <code>String</code> object that must match the     *        SQL name of a column in this rowset, ignoring case     * @param x the new column value     * @throws SQLException if (1) the given column name does not match the     *            name of a column in this rowset, (2) the cursor is not on     *            one of this rowset's rows or its insert row, or (3) this     *            rowset is <code>ResultSet.CONCUR_READ_ONLY</code>     */    public void updateByte(String columnName, byte x) throws SQLException {        updateByte(getColIdxByName(columnName), x);    }     /**     * Sets the designated column in either the current row or the insert     * row of this <code>CachedRowSetImpl</code> object with the given     * <code>short</code> value.     * <P>

Lines 4501–5000 of 10133. Previous lines