10133 lines · 431.3 KB · Java
RawDownload
    }     /**     * Retrieves the value stored in the designated column     * of the current row as a <code>byte</code> value.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return the column value as a <code>byte</code> in the Java programming     * language; if the value is SQL <code>NULL</code>, the result is <code>0</code>     * @throws SQLException if (1) the given column name is not 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) the designated     * column does not store an SQL <code><B>TINYINT</B>, SMALLINT, INTEGER,     * BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, CHAR,     * VARCHAR</code> or <code>LONGVARCHAR</code> value. The     * bold type designates the recommended return type     */    public byte getByte(String columnName) throws SQLException {        return getByte(getColIdxByName(columnName));    }     /**     * Retrieves the value stored in the designated column     * of the current row as a <code>short</code> value.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return the column value; if the value is SQL <code>NULL</code>,     *         the result is <code>0</code>     * @throws SQLException if (1) the given column name is not 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) the designated     * column does not store an SQL <code>TINYINT, <b>SMALLINT</b>, INTEGER     * BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, CHAR,     * VARCHAR</code> or <code>LONGVARCHAR</code> value. The bold SQL type     * designates the recommended return type.     * @see #getShort(int)     */    public short getShort(String columnName) throws SQLException {        return getShort(getColIdxByName(columnName));    }     /**     * Retrieves the value stored in the designated column     * of the current row as an <code>int</code> value.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return the column value; if the value is SQL <code>NULL</code>,     *         the result is <code>0</code>     * @throws SQLException if (1) the given column name is not 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) the designated column does not store an     * SQL <code>TINYINT, SMALLINT, <b>INTEGER</b>, BIGINT, REAL     * FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, CHAR, VARCHAR</code>     * or <code>LONGVARCHAR</code> value. The bold SQL type designates the     * recommended return type.     */    public int getInt(String columnName) throws SQLException {        return getInt(getColIdxByName(columnName));    }     /**     * Retrieves the value stored in the designated column     * of the current row as a <code>long</code> value.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return the column value; if the value is SQL <code>NULL</code>,     *         the result is <code>0</code>     * @throws SQLException if (1) the given column name is not 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) the designated     * column does not store an SQL <code>TINYINT, SMALLINT, INTEGER     * <b>BIGINT</b>, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, CHAR,     * VARCHAR</code> or <code>LONGVARCHAR</code> value. The bold SQL type     * designates the recommended return type.     * @see #getLong(int)     */    public long getLong(String columnName) throws SQLException {        return getLong(getColIdxByName(columnName));    }     /**     * Retrieves the value stored in the designated column     * of the current row as a <code>float</code> value.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return the column value; if the value is SQL <code>NULL</code>,     *         the result is <code>0</code>     * @throws SQLException if (1) the given column name is not 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) the designated     * column does not store an SQL <code>TINYINT, SMALLINT, INTEGER     * BIGINT, <b>REAL</b>, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, CHAR,     * VARCHAR</code> or <code>LONGVARCHAR</code> value. The bold SQL type     * designates the recommended return type.     * @see #getFloat(String)     */    public float getFloat(String columnName) throws SQLException {        return getFloat(getColIdxByName(columnName));    }     /**     * Retrieves the value stored in the designated column     * of the current row of this <code>CachedRowSetImpl</code> object     * as a <code>double</code> value.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return the column value; if the value is SQL <code>NULL</code>,     *         the result is <code>0</code>     * @throws SQLException if (1) the given column name is not 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) the designated     * column does not store an SQL <code>TINYINT, SMALLINT, INTEGER     * BIGINT, REAL, <b>FLOAT</b>, <b>DOUBLE</b>, DECIMAL, NUMERIC, BIT, CHAR,     * VARCHAR</code> or <code>LONGVARCHAR</code> value. The bold SQL type     * designates the recommended return types.     * @see #getDouble(int)     */    public double getDouble(String columnName) throws SQLException {        return getDouble(getColIdxByName(columnName));    }     /**     * Retrieves the value stored in the designated column     * of the current row as a <code>java.math.BigDecimal</code> object.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @param scale the number of digits to the right of the decimal point     * @return a java.math.BugDecimal object with <code><i>scale</i></code>     * number of digits to the right of the decimal point.     * @throws SQLException if (1) the given column name is not 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) the designated     * column does not store an SQL <code>TINYINT, SMALLINT, INTEGER     * BIGINT, REAL, FLOAT, DOUBLE, <b>DECIMAL</b>, <b>NUMERIC</b>, BIT CHAR,     * VARCHAR</code> or <code>LONGVARCHAR</code> value. The bold SQL type     * designates the recommended return type that this method is used to     * retrieve.     * @deprecated Use the <code>getBigDecimal(String columnName)</code>     *             method instead     */    public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {        return getBigDecimal(getColIdxByName(columnName), scale);    }     /**     * Retrieves the value stored in the designated column     * of the current row as a <code>byte</code> array.     * The bytes represent the raw values returned by the driver.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return the column value as a <code>byte</code> array in the Java programming     * language; if the value is SQL <code>NULL</code>, the result is <code>null</code>     * @throws SQLException if (1) the given column name is not 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) the designated     * column does not store an SQL <code><b>BINARY</b>, <b>VARBINARY</b>     * </code> or <code>LONGVARBINARY</code> values     * The bold SQL type designates the recommended return type.     * @see #getBytes(int)     */    public byte[] getBytes(String columnName) throws SQLException {        return getBytes(getColIdxByName(columnName));    }     /**     * Retrieves the value stored in the designated column     * of the current row as a <code>java.sql.Date</code> object.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return the column value; if the value is SQL <code>NULL</code>,     *         the result is <code>null</code>     * @throws SQLException if (1) the given column name is not 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) the designated     *            column does not store an SQL <code>DATE</code> or     *            <code>TIMESTAMP</code> value     */    public java.sql.Date getDate(String columnName) throws SQLException {        return getDate(getColIdxByName(columnName));    }     /**     * Retrieves the value stored in the designated column     * of the current row as a <code>java.sql.Time</code> object.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return the column value; if the value is SQL <code>NULL</code>,     *         the result is <code>null</code>     * @throws SQLException if the given column name does not match one of     *            this rowset's column names or the cursor is not on one of     *            this rowset's rows or its insert row     */    public java.sql.Time getTime(String columnName) throws SQLException {        return getTime(getColIdxByName(columnName));    }     /**     * Retrieves the value stored in the designated column     * of the current row as a <code>java.sql.Timestamp</code> object.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return the column value; if the value is SQL <code>NULL</code>,     *         the result is <code>null</code>     * @throws SQLException if the given column name does not match one of     *            this rowset's column names or the cursor is not on one of     *            this rowset's rows or its insert row     */    public java.sql.Timestamp getTimestamp(String columnName) throws SQLException {        return getTimestamp(getColIdxByName(columnName));    }     /**     * Retrieves the value of the designated column in the current row of this     * <code>CachedRowSetImpl</code> object as a <code>java.io.InputStream</code>     * object.     *     * A column value can be retrieved as a stream of ASCII characters     * and then read in chunks from the stream. This method is particularly     * suitable for retrieving large <code>LONGVARCHAR</code> values. The     * <code>SyncProvider</code> will rely on the JDBC driver to do any necessary     * conversion from the database format into ASCII format.     *     * <P><B>Note:</B> All the data in the returned stream must     * be read prior to getting the value of any other column. The     * next call to a <code>getXXX</code> method implicitly closes the stream.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return a Java input stream that delivers the database column value     *         as a stream of one-byte ASCII characters.  If the value is SQL     *         <code>NULL</code>, the result is <code>null</code>.     * @throws SQLException if (1) the given column name is not 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) the designated column does not store an     * SQL <code>CHAR, VARCHAR</code>, <code><b>LONGVARCHAR</b></code>     * <code>BINARY, VARBINARY</code> or <code>LONGVARBINARY</code> value. The     * bold SQL type designates the recommended return types that this method is     * used to retrieve.     * @see #getAsciiStream(int)     */    public java.io.InputStream getAsciiStream(String columnName) throws SQLException {        return getAsciiStream(getColIdxByName(columnName));     }     /**     * A column value can be retrieved as a stream of Unicode characters     * and then read in chunks from the stream.  This method is particularly     * suitable for retrieving large <code>LONGVARCHAR</code> values.     * The JDBC driver will do any necessary conversion from the database     * format into Unicode.     *     * <P><B>Note:</B> All the data in the returned stream must     * be read prior to getting the value of any other column. The     * next call to a <code>getXXX</code> method implicitly closes the stream.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return a Java input stream that delivers the database column value     *         as a stream of two-byte Unicode characters.  If the value is     *         SQL <code>NULL</code>, the result is <code>null</code>.     * @throws SQLException if the given column name does not match one of     *            this rowset's column names or the cursor is not on one of     *            this rowset's rows or its insert row     * @deprecated use the method <code>getCharacterStream</code> instead     */    public java.io.InputStream getUnicodeStream(String columnName) throws SQLException {        return getUnicodeStream(getColIdxByName(columnName));    }     /**     * Retrieves the value of the designated column in the current row of this     * <code>CachedRowSetImpl</code> object as a <code>java.io.InputStream</code>     * object.     * <P>     * A column value can be retrieved as a stream of uninterpreted bytes     * and then read in chunks from the stream.  This method is particularly     * suitable for retrieving large <code>LONGVARBINARY</code> values.     *     * <P><B>Note:</B> All the data in the returned stream must be     * read prior to getting the value of any other column. The next     * call to a get method implicitly closes the stream. Also, a     * stream may return <code>0</code> for <code>CachedRowSetImpl.available()</code>     * whether there is data available or not.     *     * @param columnName a <code>String</code> object giving the SQL name of     *        a column in this <code>CachedRowSetImpl</code> object     * @return a Java input stream that delivers the database column value     *         as a stream of uninterpreted bytes.  If the value is SQL     *         <code>NULL</code>, the result is <code>null</code>.     * @throws SQLException if (1) the given column name is unknown,     * (2) the cursor is not on one of this rowset's rows or its     * insert row, or (3) the designated column does not store an     * SQL <code>BINARY, VARBINARY</code> or <code><b>LONGVARBINARY</b></code>     * The bold type indicates the SQL type that this method is recommened     * to retrieve.     * @see #getBinaryStream(int)     *     */    public java.io.InputStream getBinaryStream(String columnName) throws SQLException {        return getBinaryStream(getColIdxByName(columnName));    }      // Advanced features:     /**     * The first warning reported by calls on this <code>CachedRowSetImpl</code>     * object is returned. Subsequent <code>CachedRowSetImpl</code> warnings will     * be chained to this <code>SQLWarning</code>.     *     * <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 statement     * methods (such as reading OUT parameters) will be chained on the     * <code>Statement</code> object.     *     * @return the first SQLWarning or null     */    public SQLWarning getWarnings() {        return sqlwarn;    }     /**     * Clears all the warnings reporeted for the <code>CachedRowSetImpl</code>     * object. After a call to this method, the <code>getWarnings</code> method     * returns <code>null</code> until a new warning is reported for this     * <code>CachedRowSetImpl</code> object.     */    public void clearWarnings() {        sqlwarn = null;    }     /**     * Retrieves the name of the SQL cursor used by this     * <code>CachedRowSetImpl</code> object.     *     * <P>In SQL, a result table is retrieved through a cursor that is     * named. The current row of a <code>ResultSet</code> can be updated or deleted     * using a positioned update/delete statement that references the     * cursor name. To ensure that the cursor has the proper isolation     * level to support an update operation, the cursor's <code>SELECT</code>     * statement should be of the form <code>select for update</code>.     * If the <code>for update</code> clause     * is omitted, positioned updates may fail.     *     * <P>JDBC supports this SQL feature by providing the name of the     * SQL cursor used by a <code>ResultSet</code> object. The current row     * of a result set is also the current row of this SQL cursor.     *     * <P><B>Note:</B> If positioned updates are not supported, an     * <code>SQLException</code> is thrown.     *     * @return the SQL cursor name for this <code>CachedRowSetImpl</code> object's     *         cursor     * @throws SQLException if an error occurs     */    public String getCursorName() throws SQLException {        throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.posupdate").toString());    }     /**     * Retrieves a <code>ResultSetMetaData</code> object instance that     * contains information about the <code>CachedRowSet</code> object.     * However, applications should cast the returned object to a     * <code>RowSetMetaData</code> interface implementation. In the     * reference implementation, this cast can be done on the     * <code>RowSetMetaDataImpl</code> class.     * <P>     * For example:     * <pre>     * CachedRowSet crs = new CachedRowSetImpl();     * RowSetMetaDataImpl metaData =     *     (RowSetMetaDataImpl)crs.getMetaData();     * // Set the number of columns in the RowSet object for     * // which this RowSetMetaDataImpl object was created to the     * // given number.     * metaData.setColumnCount(3);     * crs.setMetaData(metaData);     * </pre>     *     * @return the <code>ResultSetMetaData</code> object that describes this     *         <code>CachedRowSetImpl</code> object's columns     * @throws SQLException if an error occurs in generating the RowSet     * meta data; or if the <code>CachedRowSetImpl</code> is empty.     * @see javax.sql.RowSetMetaData     */    public ResultSetMetaData getMetaData() throws SQLException {        return (ResultSetMetaData)RowSetMD;    }      /**     * Retrieves the value of the designated column in the current row     * of this <code>CachedRowSetImpl</code> object as an     * <code>Object</code> value.     * <P>     * The type of the <code>Object</code> 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 3.0     * specification.     * <P>     * This method may also be used to read datatabase-specific     * abstract data types.     * <P>     * This implementation of the method <code>getObject</code> extends its     * behavior so that it gets the attributes of an SQL structured type     * as an array of <code>Object</code> values.  This method also custom     * maps SQL user-defined types to classes in the Java programming language.     * When the specified column contains     * a structured or distinct value, the behavior of this method is as     * if it were a call to the method <code>getObject(columnIndex,     * this.getStatement().getConnection().getTypeMap())</code>.     *     * @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 the rowset     * @return a <code>java.lang.Object</code> holding the column value;     *         if the value is SQL <code>NULL</code>, the result is <code>null</code>     * @throws SQLException if the given column index is out of bounds,     *            the cursor is not on a valid row, or there is a problem getting     *            the <code>Class</code> object for a custom mapping     * @see #getObject(String)     */    public Object getObject(int columnIndex) throws SQLException {        Object value;        Map<String, Class<?>> map;         // sanity check.        checkIndex(columnIndex);        // make sure the cursor is on a valid row        checkCursor();         setLastValueNull(false);        value = getCurrentRow().getColumnObject(columnIndex);         // check for SQL NULL        if (value == null) {            setLastValueNull(true);            return null;        }        if (value instanceof Struct) {            Struct s = (Struct)value;            map = getTypeMap();            // look up the class in the map            Class c = (Class)map.get(s.getSQLTypeName());            if (c != null) {                // create new instance of the class                SQLData obj = null;                try {                    obj = (SQLData)c.newInstance();                } catch (java.lang.InstantiationException ex) {                    throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),                    ex.getMessage()));                } catch (java.lang.IllegalAccessException ex) {                    throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),                    ex.getMessage()));                }                // get the attributes from the struct                Object attribs[] = s.getAttributes(map);                // create the SQLInput "stream"                SQLInputImpl sqlInput = new SQLInputImpl(attribs, map);                // read the values...                obj.readSQL(sqlInput, s.getSQLTypeName());                return (Object)obj;            }        }        return value;    }     /**     * Retrieves the value of the designated column in the current row     * of this <code>CachedRowSetImpl</code> object as an     * <code>Object</code> value.     * <P>     * The type of the <code>Object</code> 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 3.0     * specification.     * <P>     * This method may also be used to read datatabase-specific     * abstract data types.     * <P>     * This implementation of the method <code>getObject</code> extends its     * behavior so that it gets the attributes of an SQL structured type

Lines 2501–3000 of 10133. Previous lines