1095 lines · 43.7 KB · Java
RawDownload
     *         <code>false</code> otherwise     * @throws SQLException if a database access error occurs     * or the given column number is out of bounds     */    public boolean isAutoIncrement(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].autoIncrement;    }     /**     * Indicates whether the case of the designated column's name     * matters.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     * must be between <code>1</code> and the number of columns, inclusive     * @return <code>true</code> if the column name is case sensitive;     *          <code>false</code> otherwise     * @throws SQLException if a database access error occurs     * or the given column number is out of bounds     */    public boolean isCaseSensitive(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].caseSensitive;    }     /**     * Indicates whether a value stored in the designated column     * can be used in a <code>WHERE</code> clause.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     *        must be between <code>1</code> and the number of columns, inclusive     * @return <code>true</code> if a value in the designated column can be used in a     *         <code>WHERE</code> clause; <code>false</code> otherwise     * @throws SQLException if a database access error occurs     *         or the given column number is out of bounds     */    public boolean isSearchable(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].searchable;    }     /**     * Indicates whether a value stored in the designated column     * is a cash value.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     *        must be between <code>1</code> and the number of columns, inclusive     * @return <code>true</code> if a value in the designated column is a cash value;     *         <code>false</code> otherwise     * @throws SQLException if a database access error occurs     *         or the given column number is out of bounds     */    public boolean isCurrency(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].currency;    }     /**     * Retrieves a constant indicating whether it is possible     * to store a <code>NULL</code> value in the designated column.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     *        must be between <code>1</code> and the number of columns, inclusive     * @return a constant from the <code>ResultSetMetaData</code> interface;     *         either <code>columnNoNulls</code>,     *         <code>columnNullable</code>, or     *         <code>columnNullableUnknown</code>     * @throws SQLException if a database access error occurs     *         or the given column number is out of bounds     */    public int isNullable(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].nullable;    }     /**     * Indicates whether a value stored in the designated column is     * a signed number.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     *        must be between <code>1</code> and the number of columns, inclusive     * @return <code>true</code> if if a value in the designated column is a signed     *         number; <code>false</code> otherwise     * @throws SQLException if a database access error occurs     *         or the given column number is out of bounds     */    public boolean isSigned(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].signed;    }     /**     * Retrieves the normal maximum width in chars of the designated column.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     *        must be between <code>1</code> and the number of columns, inclusive     * @return the maximum number of chars that can be displayed in the designated     *         column     * @throws SQLException if a database access error occurs     *         or the given column number is out of bounds     */    public int getColumnDisplaySize(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].columnDisplaySize;    }     /**     * Retrieves the the suggested column title for the designated     * column for use in printouts and displays.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     *        must be between <code>1</code> and the number of columns, inclusive     * @return the suggested column name to use in printouts and displays     * @throws SQLException if a database access error occurs     *         or the given column number is out of bounds     */    public String getColumnLabel(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].columnLabel;    }     /**     * Retrieves the name of the designated column.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     * must be between <code>1</code> and the number of columns, inclusive     * @return the column name of the designated column     * @throws SQLException if a database access error occurs     * or the given column number is out of bounds     */    public String getColumnName(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].columnName;    }     /**     * Retrieves the schema name of the table from which the value     * in the designated column was derived.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     *         must be between <code>1</code> and the number of columns,     *         inclusive     * @return the schema name or an empty <code>String</code> if no schema     *         name is available     * @throws SQLException if a database access error occurs     * or the given column number is out of bounds     */    public String getSchemaName(int columnIndex) throws SQLException {        checkColRange(columnIndex);        String str ="";        if(colInfo[columnIndex].schemaName == null){        } else {              str = colInfo[columnIndex].schemaName;        }        return str;    }     /**     * Retrieves the total number of digits for values stored in     * the designated column.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     * must be between <code>1</code> and the number of columns, inclusive     * @return the precision for values stored in the designated column     * @throws SQLException if a database access error occurs     * or the given column number is out of bounds     */    public int getPrecision(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].colPrecision;    }     /**     * Retrieves the number of digits to the right of the decimal point     * for values stored in the designated column.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     * must be between <code>1</code> and the number of columns, inclusive     * @return the scale for values stored in the designated column     * @throws SQLException if a database access error occurs     * or the given column number is out of bounds     */    public int getScale(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].colScale;    }     /**     * Retrieves the name of the table from which the value     * in the designated column was derived.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     * must be between <code>1</code> and the number of columns, inclusive     * @return the table name or an empty <code>String</code> if no table name     *         is available     * @throws SQLException if a database access error occurs     * or the given column number is out of bounds     */    public String getTableName(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].tableName;    }     /**     * Retrieves the catalog name of the table from which the value     * in the designated column was derived.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     * must be between <code>1</code> and the number of columns, inclusive     * @return the catalog name of the column's table or an empty     *         <code>String</code> if no catalog name is available     * @throws SQLException if a database access error occurs     * or the given column number is out of bounds     */    public String getCatalogName(int columnIndex) throws SQLException {        checkColRange(columnIndex);        String str ="";        if(colInfo[columnIndex].catName == null){        } else {           str = colInfo[columnIndex].catName;        }        return str;    }     /**     * Retrieves the type code (one of the <code>java.sql.Types</code>     * constants) for the SQL type of the value stored in the     * designated column.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     * must be between <code>1</code> and the number of columns, inclusive     * @return an <code>int</code> representing the SQL type of values     * stored in the designated column     * @throws SQLException if a database access error occurs     * or the given column number is out of bounds     * @see java.sql.Types     */    public int getColumnType(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].colType;    }     /**     * Retrieves the DBMS-specific type name for values stored in the     * designated column.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     * must be between <code>1</code> and the number of columns, inclusive     * @return the type name used by the data source     * @throws SQLException if a database access error occurs     * or the given column number is out of bounds     */    public String getColumnTypeName(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].colTypeName;    }      /**     * Indicates whether the designated column is definitely     * not writable, thus readonly.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     * must be between <code>1</code> and the number of columns, inclusive     * @return <code>true</code> if this <code>RowSet</code> object is read-Only     * and thus not updatable; <code>false</code> otherwise     * @throws SQLException if a database access error occurs     * or the given column number is out of bounds     */    public boolean isReadOnly(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].readOnly;    }     /**     * Indicates whether it is possible for a write operation on     * the designated column to succeed. A return value of     * <code>true</code> means that a write operation may or may     * not succeed.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     *         must be between <code>1</code> and the number of columns, inclusive     * @return <code>true</code> if a write operation on the designated column may     *          will succeed; <code>false</code> otherwise     * @throws SQLException if a database access error occurs     *         or the given column number is out of bounds     */    public boolean isWritable(int columnIndex) throws SQLException {        checkColRange(columnIndex);        return colInfo[columnIndex].writable;    }     /**     * Indicates whether a write operation on the designated column     * will definitely succeed.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     * must be between <code>1</code> and the number of columns, inclusive     * @return <code>true</code> if a write operation on the designated column will     *         definitely succeed; <code>false</code> otherwise     * @throws SQLException if a database access error occurs     * or the given column number is out of bounds     */    public  boolean isDefinitelyWritable(int columnIndex)        throws SQLException { return true;}     /**     * Retrieves the fully-qualified name of the class in the Java     * programming language to which a value in the designated column     * will be mapped.  For example, if the value is an <code>int</code>,     * the class name returned by this method will be     * <code>java.lang.Integer</code>.     * <P>     * If the value in the designated column has a custom mapping,     * this method returns the name of the class that implements     * <code>SQLData</code>. When the method <code>ResultSet.getObject</code>     * is called to retrieve a value from the designated column, it will     * create an instance of this class or one of its subclasses.     *     * @param columnIndex the first column is 1, the second is 2, and so on;     *        must be between <code>1</code> and the number of columns, inclusive     * @return the fully-qualified name of the class in the Java programming     *        language that would be used by the method <code>RowSet.getObject</code> to     *        retrieve the value in the specified column. This is the class     *        name used for custom mapping when there is a custom mapping.     * @throws SQLException if a database access error occurs     *         or the given column number is out of bounds     */    public String getColumnClassName(int columnIndex) throws SQLException {        String className = String.class.getName();         int sqlType = getColumnType(columnIndex);         switch (sqlType) {         case Types.NUMERIC:        case Types.DECIMAL:            className = java.math.BigDecimal.class.getName();            break;         case Types.BIT:            className = java.lang.Boolean.class.getName();            break;         case Types.TINYINT:            className = java.lang.Byte.class.getName();            break;         case Types.SMALLINT:            className = java.lang.Short.class.getName();            break;         case Types.INTEGER:            className = java.lang.Integer.class.getName();            break;         case Types.BIGINT:            className = java.lang.Long.class.getName();            break;         case Types.REAL:            className = java.lang.Float.class.getName();            break;         case Types.FLOAT:        case Types.DOUBLE:            className = java.lang.Double.class.getName();            break;         case Types.BINARY:        case Types.VARBINARY:        case Types.LONGVARBINARY:            className = "byte[]";            break;         case Types.DATE:            className = java.sql.Date.class.getName();            break;         case Types.TIME:            className = java.sql.Time.class.getName();            break;         case Types.TIMESTAMP:            className = java.sql.Timestamp.class.getName();            break;         case Types.BLOB:            className = java.sql.Blob.class.getName();            break;         case Types.CLOB:            className = java.sql.Clob.class.getName();            break;        }         return className;    }     /**     * Returns an object that implements the given interface to allow access to non-standard methods,     * or standard methods not exposed by the proxy.     * The result may be either the object found to implement the interface or a proxy for that object.     * If the receiver implements the interface then that is the object. If the receiver is a wrapper     * and the wrapped object implements the interface then that is the object. Otherwise the object is     *  the result of calling <code>unwrap</code> recursively on the wrapped object. If the receiver is not a     * wrapper and does not implement the interface, then an <code>SQLException</code> is thrown.     *     * @param iface A Class defining an interface that the result must implement.     * @return an object that implements the interface. May be a proxy for the actual implementing object.     * @throws java.sql.SQLException If no object found that implements the interface     * @since 1.6     */    public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException {         if(isWrapperFor(iface)) {            return iface.cast(this);        } else {            throw new SQLException("unwrap failed for:"+ iface);        }    }     /**     * Returns true if this either implements the interface argument or is directly or indirectly a wrapper     * for an object that does. Returns false otherwise. If this implements the interface then return true,     * else if this is a wrapper then return the result of recursively calling <code>isWrapperFor</code> on the wrapped     * object. If this does not implement the interface and is not a wrapper, return false.     * This method should be implemented as a low-cost operation compared to <code>unwrap</code> so that     * callers can use this method to avoid expensive <code>unwrap</code> calls that may fail. If this method     * returns true then calling <code>unwrap</code> with the same argument should succeed.     *     * @param interfaces a Class defining an interface.     * @return true if this implements the interface or directly or indirectly wraps an object that does.     * @throws java.sql.SQLException  if an error occurs while determining whether this is a wrapper     * for an object with the given interface.     * @since 1.6     */    public boolean isWrapperFor(Class<?> interfaces) throws SQLException {        return interfaces.isInstance(this);    }     static final long serialVersionUID = 6893806403181801867L;     private class ColInfo implements Serializable {        /**         * The field that indicates whether the value in this column is a number         * that is incremented automatically, which makes the value read-only.         * <code>true</code> means that the value in this column         * is automatically numbered; <code>false</code> means that it is not.         *         * @serial         */        public boolean autoIncrement;         /**         * The field that indicates whether the value in this column is case sensitive.         * <code>true</code> means that it is; <code>false</code> that it is not.         *         * @serial         */        public boolean caseSensitive;         /**         * The field that indicates whether the value in this column is a cash value         * <code>true</code> means that it is; <code>false</code> that it is not.         *         * @serial         */        public boolean currency;         /**         * The field that indicates whether the value in this column is nullable.         * The possible values are the <code>ResultSet</code> constants         * <code>columnNoNulls</code>, <code>columnNullable</code>, and         * <code>columnNullableUnknown</code>.         *         * @serial         */        public int nullable;         /**         * The field that indicates whether the value in this column is a signed number.         * <code>true</code> means that it is; <code>false</code> that it is not.         *         * @serial         */        public boolean signed;         /**         * The field that indicates whether the value in this column can be used in         * a <code>WHERE</code> clause.         * <code>true</code> means that it can; <code>false</code> that it cannot.         *         * @serial         */        public boolean searchable;         /**         * The field that indicates the normal maximum width in characters for         * this column.

Lines 501–1000 of 1095. Previous lines