0N/A/*
2823N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.sql.rowset;
0N/A
0N/Aimport java.sql.*;
0N/Aimport javax.sql.*;
0N/Aimport java.io.*;
0N/A
0N/Aimport java.lang.reflect.*;
0N/A
0N/A/**
0N/A * Provides implementations for the methods that set and get
0N/A * metadata information about a <code>RowSet</code> object's columns.
0N/A * A <code>RowSetMetaDataImpl</code> object keeps track of the
0N/A * number of columns in the rowset and maintains an internal array
0N/A * of column attributes for each column.
0N/A * <P>
0N/A * A <code>RowSet</code> object creates a <code>RowSetMetaDataImpl</code>
0N/A * object internally in order to set and retrieve information about
0N/A * its columns.
0N/A * <P>
0N/A * NOTE: All metadata in a <code>RowSetMetaDataImpl</code> object
0N/A * should be considered as unavailable until the <code>RowSet</code> object
0N/A * that it describes is populated.
0N/A * Therefore, any <code>RowSetMetaDataImpl</code> method that retrieves information
0N/A * is defined as having unspecified behavior when it is called
0N/A * before the <code>RowSet</code> object contains data.
0N/A */
0N/Apublic class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
0N/A
0N/A /**
0N/A * The number of columns in the <code>RowSet</code> object that created
0N/A * this <code>RowSetMetaDataImpl</code> object.
0N/A * @serial
0N/A */
0N/A private int colCount;
0N/A
0N/A /**
0N/A * An array of <code>ColInfo</code> objects used to store information
0N/A * about each column in the <code>RowSet</code> object for which
0N/A * this <code>RowSetMetaDataImpl</code> object was created. The first
0N/A * <code>ColInfo</code> object in this array contains information about
0N/A * the first column in the <code>RowSet</code> object, the second element
0N/A * contains information about the second column, and so on.
0N/A * @serial
0N/A */
0N/A private ColInfo[] colInfo;
0N/A
0N/A /**
0N/A * Checks to see that the designated column is a valid column number for
0N/A * the <code>RowSet</code> object for which this <code>RowSetMetaDataImpl</code>
0N/A * was created. To be valid, a column number must be greater than
0N/A * <code>0</code> and less than or equal to the number of columns in a row.
0N/A * @throws <code>SQLException</code> with the message "Invalid column index"
0N/A * if the given column number is out of the range of valid column
0N/A * numbers for the <code>RowSet</code> object
0N/A */
0N/A private void checkColRange(int col) throws SQLException {
0N/A if (col <= 0 || col > colCount) {
0N/A throw new SQLException("Invalid column index :"+col);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Checks to see that the given SQL type is a valid column type and throws an
0N/A * <code>SQLException</code> object if it is not.
0N/A * To be valid, a SQL type must be one of the constant values
0N/A * in the <code><a href="../../sql/Types.html">java.sql.Types</a></code>
0N/A * class.
0N/A *
0N/A * @param SQLType an <code>int</code> defined in the class <code>java.sql.Types</code>
0N/A * @throws SQLException if the given <code>int</code> is not a constant defined in the
0N/A * class <code>java.sql.Types</code>
0N/A */
0N/A private void checkColType(int SQLType) throws SQLException {
0N/A try {
0N/A Class c = java.sql.Types.class;
0N/A Field[] publicFields = c.getFields();
0N/A int fieldValue = 0;
0N/A for (int i = 0; i < publicFields.length; i++) {
0N/A fieldValue = publicFields[i].getInt(c);
0N/A if (fieldValue == SQLType) {
0N/A return;
0N/A }
0N/A }
0N/A } catch (Exception e) {
0N/A throw new SQLException(e.getMessage());
0N/A }
0N/A throw new SQLException("Invalid SQL type for column");
0N/A }
0N/A
0N/A /**
0N/A * Sets to the given number the number of columns in the <code>RowSet</code>
0N/A * object for which this <code>RowSetMetaDataImpl</code> object was created.
0N/A *
0N/A * @param columnCount an <code>int</code> giving the number of columns in the
0N/A * <code>RowSet</code> object
0N/A * @throws SQLException if the given number is equal to or less than zero
0N/A */
0N/A public void setColumnCount(int columnCount) throws SQLException {
0N/A
0N/A if (columnCount <= 0) {
0N/A throw new SQLException("Invalid column count. Cannot be less " +
0N/A "or equal to zero");
0N/A }
0N/A
0N/A colCount = columnCount;
0N/A
0N/A // If the colCount is Integer.MAX_VALUE,
0N/A // we do not initialize the colInfo object.
0N/A // even if we try to initialize the colCount with
0N/A // colCount = Integer.MAx_VALUE-1, the colInfo
0N/A // initialization fails throwing an ERROR
0N/A // OutOfMemory Exception. So we do not initialize
0N/A // colInfo at Integer.MAX_VALUE. This is to pass TCK.
0N/A
0N/A if(!(colCount == Integer.MAX_VALUE)) {
0N/A colInfo = new ColInfo[colCount + 1];
0N/A
0N/A for (int i=1; i <= colCount; i++) {
0N/A colInfo[i] = new ColInfo();
0N/A }
0N/A }
0N/A
0N/A
0N/A }
0N/A
0N/A /**
0N/A * Sets whether the designated column is automatically
0N/A * numbered, thus read-only, to the given <code>boolean</code>
0N/A * value.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns
0N/A * in the rowset, inclusive
0N/A * @param property <code>true</code> if the given column is
0N/A * automatically incremented; <code>false</code>
0N/A * otherwise
0N/A * @throws <code>SQLException</code> if a database access error occurs or
0N/A * the given index is out of bounds
0N/A */
0N/A public void setAutoIncrement(int columnIndex, boolean property) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A colInfo[columnIndex].autoIncrement = property;
0N/A }
0N/A
0N/A /**
0N/A * Sets whether the name of the designated column is case sensitive to
0N/A * the given <code>boolean</code>.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns
0N/A * in the rowset, inclusive
0N/A * @param property <code>true</code> to indicate that the column
0N/A * name is case sensitive; <code>false</code> otherwise
0N/A * @throws SQLException if a database access error occurs or
0N/A * the given column number is out of bounds
0N/A */
0N/A public void setCaseSensitive(int columnIndex, boolean property) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A colInfo[columnIndex].caseSensitive = property;
0N/A }
0N/A
0N/A /**
0N/A * Sets whether a value stored in the designated column can be used
0N/A * in a <code>WHERE</code> clause to the given <code>boolean</code> value.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number
0N/A * of columns in the rowset, inclusive
0N/A * @param property <code>true</code> to indicate that a column
0N/A * value can be used in a <code>WHERE</code> clause;
0N/A * <code>false</code> otherwise
0N/A *
0N/A * @throws <code>SQLException</code> if a database access error occurs or
0N/A * the given column number is out of bounds
0N/A */
0N/A public void setSearchable(int columnIndex, boolean property)
0N/A throws SQLException {
0N/A checkColRange(columnIndex);
0N/A colInfo[columnIndex].searchable = property;
0N/A }
0N/A
0N/A /**
0N/A * Sets whether a value stored in the designated column is a cash
0N/A * value to the given <code>boolean</code>.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns,
0N/A * inclusive between <code>1</code> and the number of columns, inclusive
0N/A * @param property true if the value is a cash value; false otherwise.
0N/A * @throws <code>SQLException</code> if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public void setCurrency(int columnIndex, boolean property)
0N/A throws SQLException {
0N/A checkColRange(columnIndex);
0N/A colInfo[columnIndex].currency = property;
0N/A }
0N/A
0N/A /**
0N/A * Sets whether a value stored in the designated column can be set
0N/A * to <code>NULL</code> to the given constant from the interface
0N/A * <code>ResultSetMetaData</code>.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @param property one of the following <code>ResultSetMetaData</code> constants:
0N/A * <code>columnNoNulls</code>,
0N/A * <code>columnNullable</code>, or
0N/A * <code>columnNullableUnknown</code>
0N/A *
0N/A * @throws <code>SQLException</code> if a database access error occurs,
0N/A * the given column number is out of bounds, or the value supplied
0N/A * for the <i>property</i> parameter is not one of the following
0N/A * constants:
0N/A * <code>ResultSetMetaData.columnNoNulls</code>,
0N/A * <code>ResultSetMetaData.columnNullable</code>, or
0N/A * <code>ResultSetMetaData.columnNullableUnknown</code>
0N/A */
0N/A public void setNullable(int columnIndex, int property) throws SQLException {
0N/A if ((property < ResultSetMetaData.columnNoNulls) ||
0N/A property > ResultSetMetaData.columnNullableUnknown) {
0N/A throw new SQLException("Invalid nullable constant set. Must be " +
0N/A "either columnNoNulls, columnNullable or columnNullableUnknown");
0N/A }
0N/A checkColRange(columnIndex);
0N/A colInfo[columnIndex].nullable = property;
0N/A }
0N/A
0N/A /**
0N/A * Sets whether a value stored in the designated column is a signed
0N/A * number to the given <code>boolean</code>.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @param property <code>true</code> to indicate that a column
0N/A * value is a signed number;
0N/A * <code>false</code> to indicate that it is not
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public void setSigned(int columnIndex, boolean property) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A colInfo[columnIndex].signed = property;
0N/A }
0N/A
0N/A /**
0N/A * Sets the normal maximum number of chars in the designated column
0N/A * to the given number.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @param size the maximum size of the column in chars; must be
0N/A * <code>0</code> or more
0N/A * @throws SQLException if a database access error occurs,
0N/A * the given column number is out of bounds, or <i>size</i> is
0N/A * less than <code>0</code>
0N/A */
0N/A public void setColumnDisplaySize(int columnIndex, int size) throws SQLException {
0N/A if (size < 0) {
0N/A throw new SQLException("Invalid column display size. Cannot be less " +
0N/A "than zero");
0N/A }
0N/A checkColRange(columnIndex);
0N/A colInfo[columnIndex].columnDisplaySize = size;
0N/A }
0N/A
0N/A /**
0N/A * Sets the suggested column label for use in printouts and
0N/A * displays, if any, to <i>label</i>. If <i>label</i> is
0N/A * <code>null</code>, the column label is set to an empty string
0N/A * ("").
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @param label the column label to be used in printouts and displays; if the
0N/A * column label is <code>null</code>, an empty <code>String</code> is
0N/A * set
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column index is out of bounds
0N/A */
0N/A public void setColumnLabel(int columnIndex, String label) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A if (label != null) {
2823N/A colInfo[columnIndex].columnLabel = label;
0N/A } else {
2823N/A colInfo[columnIndex].columnLabel = "";
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Sets the column name of the designated column to the given name.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @param columnName a <code>String</code> object indicating the column name;
0N/A * if the given name is <code>null</code>, an empty <code>String</code>
0N/A * is set
0N/A * @throws SQLException if a database access error occurs or the given column
0N/A * index is out of bounds
0N/A */
0N/A public void setColumnName(int columnIndex, String columnName) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A if (columnName != null) {
2823N/A colInfo[columnIndex].columnName = columnName;
0N/A } else {
2823N/A colInfo[columnIndex].columnName = "";
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Sets the designated column's table's schema name, if any, to
0N/A * <i>schemaName</i>. If <i>schemaName</i> is <code>null</code>,
0N/A * the schema name is set to an empty string ("").
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @param schemaName the schema name for the table from which a value in the
0N/A * designated column was derived; may be an empty <code>String</code>
0N/A * or <code>null</code>
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public void setSchemaName(int columnIndex, String schemaName) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A if (schemaName != null ) {
2823N/A colInfo[columnIndex].schemaName = schemaName;
0N/A } else {
2823N/A colInfo[columnIndex].schemaName = "";
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Sets the total number of decimal digits in a value stored in the
0N/A * designated column to the given number.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @param precision the total number of decimal digits; must be <code>0</code>
0N/A * or more
0N/A * @throws SQLException if a database access error occurs,
0N/A * <i>columnIndex</i> is out of bounds, or <i>precision</i>
0N/A * is less than <code>0</code>
0N/A */
0N/A public void setPrecision(int columnIndex, int precision) throws SQLException {
0N/A
0N/A if (precision < 0) {
0N/A throw new SQLException("Invalid precision value. Cannot be less " +
0N/A "than zero");
0N/A }
0N/A checkColRange(columnIndex);
0N/A colInfo[columnIndex].colPrecision = precision;
0N/A }
0N/A
0N/A /**
0N/A * Sets the number of digits to the right of the decimal point in a value
0N/A * stored in the designated column to the given number.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @param scale the number of digits to the right of the decimal point; must be
0N/A * zero or greater
0N/A * @throws SQLException if a database access error occurs,
0N/A * <i>columnIndex</i> is out of bounds, or <i>scale</i>
0N/A * is less than <code>0</code>
0N/A */
0N/A public void setScale(int columnIndex, int scale) throws SQLException {
0N/A if (scale < 0) {
0N/A throw new SQLException("Invalid scale size. Cannot be less " +
0N/A "than zero");
0N/A }
0N/A checkColRange(columnIndex);
0N/A colInfo[columnIndex].colScale = scale;
0N/A }
0N/A
0N/A /**
0N/A * Sets the name of the table from which the designated column
0N/A * was derived to the given table name.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @param tableName the column's table name; may be <code>null</code> or an
0N/A * empty string
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public void setTableName(int columnIndex, String tableName) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A if (tableName != null) {
2823N/A colInfo[columnIndex].tableName = tableName;
0N/A } else {
2823N/A colInfo[columnIndex].tableName = "";
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Sets the catalog name of the table from which the designated
0N/A * column was derived to <i>catalogName</i>. If <i>catalogName</i>
0N/A * is <code>null</code>, the catalog name is set to an empty string.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @param catalogName the column's table's catalog name; if the catalogName
0N/A * is <code>null</code>, an empty <code>String</code> is set
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public void setCatalogName(int columnIndex, String catalogName) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A if (catalogName != null)
2823N/A colInfo[columnIndex].catName = catalogName;
0N/A else
2823N/A colInfo[columnIndex].catName = "";
0N/A }
0N/A
0N/A /**
0N/A * Sets the SQL type code for values stored in the designated column
0N/A * to the given type code from the class <code>java.sql.Types</code>.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @param SQLType the designated column's SQL type, which must be one of the
0N/A * constants in the class <code>java.sql.Types</code>
0N/A * @throws SQLException if a database access error occurs,
0N/A * the given column number is out of bounds, or the column type
0N/A * specified is not one of the constants in
0N/A * <code>java.sql.Types</code>
0N/A * @see java.sql.Types
0N/A */
0N/A public void setColumnType(int columnIndex, int SQLType) throws SQLException {
0N/A // examine java.sql.Type reflectively, loop on the fields and check
0N/A // this. Separate out into a private method
0N/A checkColType(SQLType);
0N/A checkColRange(columnIndex);
0N/A colInfo[columnIndex].colType = SQLType;
0N/A }
0N/A
0N/A /**
0N/A * Sets the type name used by the data source for values stored in the
0N/A * designated column to the given type name.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @param typeName the data source-specific type name; if <i>typeName</i> is
0N/A * <code>null</code>, an empty <code>String</code> is set
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public void setColumnTypeName(int columnIndex, String typeName)
0N/A throws SQLException {
0N/A checkColRange(columnIndex);
0N/A if (typeName != null) {
2823N/A colInfo[columnIndex].colTypeName = typeName;
0N/A } else {
2823N/A colInfo[columnIndex].colTypeName = "";
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the number of columns in the <code>RowSet</code> object
0N/A * for which this <code>RowSetMetaDataImpl</code> object was created.
0N/A *
0N/A * @return the number of columns
0N/A * @throws SQLException if an error occurs determining the column count
0N/A */
0N/A public int getColumnCount() throws SQLException {
0N/A return colCount;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves whether a value stored in the designated column is
0N/A * automatically numbered, and thus readonly.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return <code>true</code> if the column is automatically numbered;
0N/A * <code>false</code> otherwise
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public boolean isAutoIncrement(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].autoIncrement;
0N/A }
0N/A
0N/A /**
0N/A * Indicates whether the case of the designated column's name
0N/A * matters.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return <code>true</code> if the column name is case sensitive;
0N/A * <code>false</code> otherwise
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public boolean isCaseSensitive(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].caseSensitive;
0N/A }
0N/A
0N/A /**
0N/A * Indicates whether a value stored in the designated column
0N/A * can be used in a <code>WHERE</code> clause.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return <code>true</code> if a value in the designated column can be used in a
0N/A * <code>WHERE</code> clause; <code>false</code> otherwise
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public boolean isSearchable(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].searchable;
0N/A }
0N/A
0N/A /**
0N/A * Indicates whether a value stored in the designated column
0N/A * is a cash value.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return <code>true</code> if a value in the designated column is a cash value;
0N/A * <code>false</code> otherwise
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public boolean isCurrency(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].currency;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves a constant indicating whether it is possible
0N/A * to store a <code>NULL</code> value in the designated column.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return a constant from the <code>ResultSetMetaData</code> interface;
0N/A * either <code>columnNoNulls</code>,
0N/A * <code>columnNullable</code>, or
0N/A * <code>columnNullableUnknown</code>
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public int isNullable(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].nullable;
0N/A }
0N/A
0N/A /**
0N/A * Indicates whether a value stored in the designated column is
0N/A * a signed number.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return <code>true</code> if if a value in the designated column is a signed
0N/A * number; <code>false</code> otherwise
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public boolean isSigned(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].signed;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the normal maximum width in chars of the designated column.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return the maximum number of chars that can be displayed in the designated
0N/A * column
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public int getColumnDisplaySize(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].columnDisplaySize;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the the suggested column title for the designated
0N/A * column for use in printouts and displays.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return the suggested column name to use in printouts and displays
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public String getColumnLabel(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].columnLabel;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the name of the designated column.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return the column name of the designated column
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public String getColumnName(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].columnName;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the schema name of the table from which the value
0N/A * in the designated column was derived.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns,
0N/A * inclusive
0N/A * @return the schema name or an empty <code>String</code> if no schema
0N/A * name is available
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public String getSchemaName(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A String str ="";
0N/A if(colInfo[columnIndex].schemaName == null){
0N/A } else {
0N/A str = colInfo[columnIndex].schemaName;
0N/A }
0N/A return str;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the total number of digits for values stored in
0N/A * the designated column.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return the precision for values stored in the designated column
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public int getPrecision(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].colPrecision;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the number of digits to the right of the decimal point
0N/A * for values stored in the designated column.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return the scale for values stored in the designated column
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public int getScale(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].colScale;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the name of the table from which the value
0N/A * in the designated column was derived.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return the table name or an empty <code>String</code> if no table name
0N/A * is available
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public String getTableName(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].tableName;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the catalog name of the table from which the value
0N/A * in the designated column was derived.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return the catalog name of the column's table or an empty
0N/A * <code>String</code> if no catalog name is available
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public String getCatalogName(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A String str ="";
0N/A if(colInfo[columnIndex].catName == null){
0N/A } else {
0N/A str = colInfo[columnIndex].catName;
0N/A }
0N/A return str;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the type code (one of the <code>java.sql.Types</code>
0N/A * constants) for the SQL type of the value stored in the
0N/A * designated column.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return an <code>int</code> representing the SQL type of values
0N/A * stored in the designated column
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A * @see java.sql.Types
0N/A */
0N/A public int getColumnType(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].colType;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the DBMS-specific type name for values stored in the
0N/A * designated column.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return the type name used by the data source
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public String getColumnTypeName(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].colTypeName;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Indicates whether the designated column is definitely
0N/A * not writable, thus readonly.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return <code>true</code> if this <code>RowSet</code> object is read-Only
0N/A * and thus not updatable; <code>false</code> otherwise
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public boolean isReadOnly(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].readOnly;
0N/A }
0N/A
0N/A /**
0N/A * Indicates whether it is possible for a write operation on
0N/A * the designated column to succeed. A return value of
0N/A * <code>true</code> means that a write operation may or may
0N/A * not succeed.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return <code>true</code> if a write operation on the designated column may
0N/A * will succeed; <code>false</code> otherwise
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public boolean isWritable(int columnIndex) throws SQLException {
0N/A checkColRange(columnIndex);
0N/A return colInfo[columnIndex].writable;
0N/A }
0N/A
0N/A /**
0N/A * Indicates whether a write operation on the designated column
0N/A * will definitely succeed.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return <code>true</code> if a write operation on the designated column will
0N/A * definitely succeed; <code>false</code> otherwise
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public boolean isDefinitelyWritable(int columnIndex)
0N/A throws SQLException { return true;}
0N/A
0N/A /**
0N/A * Retrieves the fully-qualified name of the class in the Java
0N/A * programming language to which a value in the designated column
0N/A * will be mapped. For example, if the value is an <code>int</code>,
0N/A * the class name returned by this method will be
0N/A * <code>java.lang.Integer</code>.
0N/A * <P>
0N/A * If the value in the designated column has a custom mapping,
0N/A * this method returns the name of the class that implements
0N/A * <code>SQLData</code>. When the method <code>ResultSet.getObject</code>
0N/A * is called to retrieve a value from the designated column, it will
0N/A * create an instance of this class or one of its subclasses.
0N/A *
0N/A * @param columnIndex the first column is 1, the second is 2, and so on;
0N/A * must be between <code>1</code> and the number of columns, inclusive
0N/A * @return the fully-qualified name of the class in the Java programming
0N/A * language that would be used by the method <code>RowSet.getObject</code> to
0N/A * retrieve the value in the specified column. This is the class
0N/A * name used for custom mapping when there is a custom mapping.
0N/A * @throws SQLException if a database access error occurs
0N/A * or the given column number is out of bounds
0N/A */
0N/A public String getColumnClassName(int columnIndex) throws SQLException {
2823N/A String className = String.class.getName();
0N/A
0N/A int sqlType = getColumnType(columnIndex);
0N/A
0N/A switch (sqlType) {
0N/A
0N/A case Types.NUMERIC:
0N/A case Types.DECIMAL:
2823N/A className = java.math.BigDecimal.class.getName();
0N/A break;
0N/A
0N/A case Types.BIT:
2823N/A className = java.lang.Boolean.class.getName();
0N/A break;
0N/A
0N/A case Types.TINYINT:
2823N/A className = java.lang.Byte.class.getName();
0N/A break;
0N/A
0N/A case Types.SMALLINT:
2823N/A className = java.lang.Short.class.getName();
0N/A break;
0N/A
0N/A case Types.INTEGER:
2823N/A className = java.lang.Integer.class.getName();
0N/A break;
0N/A
0N/A case Types.BIGINT:
2823N/A className = java.lang.Long.class.getName();
0N/A break;
0N/A
0N/A case Types.REAL:
2823N/A className = java.lang.Float.class.getName();
0N/A break;
0N/A
0N/A case Types.FLOAT:
0N/A case Types.DOUBLE:
2823N/A className = java.lang.Double.class.getName();
0N/A break;
0N/A
0N/A case Types.BINARY:
0N/A case Types.VARBINARY:
0N/A case Types.LONGVARBINARY:
2823N/A className = "byte[]";
0N/A break;
0N/A
0N/A case Types.DATE:
2823N/A className = java.sql.Date.class.getName();
0N/A break;
0N/A
0N/A case Types.TIME:
2823N/A className = java.sql.Time.class.getName();
0N/A break;
0N/A
0N/A case Types.TIMESTAMP:
2823N/A className = java.sql.Timestamp.class.getName();
0N/A break;
0N/A
0N/A case Types.BLOB:
2823N/A className = java.sql.Blob.class.getName();
0N/A break;
0N/A
0N/A case Types.CLOB:
2823N/A className = java.sql.Clob.class.getName();
0N/A break;
0N/A }
0N/A
0N/A return className;
0N/A }
0N/A
0N/A /**
0N/A * Returns an object that implements the given interface to allow access to non-standard methods,
0N/A * or standard methods not exposed by the proxy.
0N/A * The result may be either the object found to implement the interface or a proxy for that object.
0N/A * If the receiver implements the interface then that is the object. If the receiver is a wrapper
0N/A * and the wrapped object implements the interface then that is the object. Otherwise the object is
0N/A * the result of calling <code>unwrap</code> recursively on the wrapped object. If the receiver is not a
0N/A * wrapper and does not implement the interface, then an <code>SQLException</code> is thrown.
0N/A *
0N/A * @param iface A Class defining an interface that the result must implement.
0N/A * @return an object that implements the interface. May be a proxy for the actual implementing object.
0N/A * @throws java.sql.SQLException If no object found that implements the interface
0N/A * @since 1.6
0N/A */
0N/A public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException {
3999N/A
3999N/A if(isWrapperFor(iface)) {
3999N/A return iface.cast(this);
3999N/A } else {
3999N/A throw new SQLException("unwrap failed for:"+ iface);
3999N/A }
0N/A }
0N/A
0N/A /**
0N/A * Returns true if this either implements the interface argument or is directly or indirectly a wrapper
0N/A * for an object that does. Returns false otherwise. If this implements the interface then return true,
0N/A * else if this is a wrapper then return the result of recursively calling <code>isWrapperFor</code> on the wrapped
0N/A * object. If this does not implement the interface and is not a wrapper, return false.
0N/A * This method should be implemented as a low-cost operation compared to <code>unwrap</code> so that
0N/A * callers can use this method to avoid expensive <code>unwrap</code> calls that may fail. If this method
0N/A * returns true then calling <code>unwrap</code> with the same argument should succeed.
0N/A *
0N/A * @param interfaces a Class defining an interface.
0N/A * @return true if this implements the interface or directly or indirectly wraps an object that does.
0N/A * @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper
0N/A * for an object with the given interface.
0N/A * @since 1.6
3999N/A */
3999N/A public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
3999N/A return interfaces.isInstance(this);
0N/A }
0N/A
0N/A static final long serialVersionUID = 6893806403181801867L;
0N/A
0N/A private class ColInfo implements Serializable {
0N/A /**
0N/A * The field that indicates whether the value in this column is a number
0N/A * that is incremented automatically, which makes the value read-only.
0N/A * <code>true</code> means that the value in this column
0N/A * is automatically numbered; <code>false</code> means that it is not.
0N/A *
0N/A * @serial
0N/A */
0N/A public boolean autoIncrement;
0N/A
0N/A /**
0N/A * The field that indicates whether the value in this column is case sensitive.
0N/A * <code>true</code> means that it is; <code>false</code> that it is not.
0N/A *
0N/A * @serial
0N/A */
0N/A public boolean caseSensitive;
0N/A
0N/A /**
0N/A * The field that indicates whether the value in this column is a cash value
0N/A * <code>true</code> means that it is; <code>false</code> that it is not.
0N/A *
0N/A * @serial
0N/A */
0N/A public boolean currency;
0N/A
0N/A /**
0N/A * The field that indicates whether the value in this column is nullable.
0N/A * The possible values are the <code>ResultSet</code> constants
0N/A * <code>columnNoNulls</code>, <code>columnNullable</code>, and
0N/A * <code>columnNullableUnknown</code>.
0N/A *
0N/A * @serial
0N/A */
0N/A public int nullable;
0N/A
0N/A /**
0N/A * The field that indicates whether the value in this column is a signed number.
0N/A * <code>true</code> means that it is; <code>false</code> that it is not.
0N/A *
0N/A * @serial
0N/A */
0N/A public boolean signed;
0N/A
0N/A /**
0N/A * The field that indicates whether the value in this column can be used in
0N/A * a <code>WHERE</code> clause.
0N/A * <code>true</code> means that it can; <code>false</code> that it cannot.
0N/A *
0N/A * @serial
0N/A */
0N/A public boolean searchable;
0N/A
0N/A /**
0N/A * The field that indicates the normal maximum width in characters for
0N/A * this column.
0N/A *
0N/A * @serial
0N/A */
0N/A public int columnDisplaySize;
0N/A
0N/A /**
0N/A * The field that holds the suggested column title for this column, to be
0N/A * used in printing and displays.
0N/A *
0N/A * @serial
0N/A */
0N/A public String columnLabel;
0N/A
0N/A /**
0N/A * The field that holds the name of this column.
0N/A *
0N/A * @serial
0N/A */
0N/A public String columnName;
0N/A
0N/A /**
0N/A * The field that holds the schema name for the table from which this column
0N/A * was derived.
0N/A *
0N/A * @serial
0N/A */
0N/A public String schemaName;
0N/A
0N/A /**
0N/A * The field that holds the precision of the value in this column. For number
0N/A * types, the precision is the total number of decimal digits; for character types,
0N/A * it is the maximum number of characters; for binary types, it is the maximum
0N/A * length in bytes.
0N/A *
0N/A * @serial
0N/A */
0N/A public int colPrecision;
0N/A
0N/A /**
0N/A * The field that holds the scale (number of digits to the right of the decimal
0N/A * point) of the value in this column.
0N/A *
0N/A * @serial
0N/A */
0N/A public int colScale;
0N/A
0N/A /**
0N/A * The field that holds the name of the table from which this column
0N/A * was derived. This value may be the empty string if there is no
0N/A * table name, such as when this column is produced by a join.
0N/A *
0N/A * @serial
0N/A */
0N/A public String tableName ="";
0N/A
0N/A /**
0N/A * The field that holds the catalog name for the table from which this column
0N/A * was derived. If the DBMS does not support catalogs, the value may be the
0N/A * empty string.
0N/A *
0N/A * @serial
0N/A */
0N/A public String catName;
0N/A
0N/A /**
0N/A * The field that holds the type code from the class <code>java.sql.Types</code>
0N/A * indicating the type of the value in this column.
0N/A *
0N/A * @serial
0N/A */
0N/A public int colType;
0N/A
0N/A /**
0N/A * The field that holds the the type name used by this particular data source
0N/A * for the value stored in this column.
0N/A *
0N/A * @serial
0N/A */
0N/A public String colTypeName;
0N/A
0N/A /**
0N/A * The field that holds the updatablity boolean per column of a RowSet
0N/A *
0N/A * @serial
0N/A */
0N/A public boolean readOnly = false;
0N/A
0N/A /**
0N/A * The field that hold the writable boolean per column of a RowSet
0N/A *
0N/A *@serial
0N/A */
0N/A public boolean writable = true;
0N/A }
0N/A}