Class com.ibm.db.StatementMetaData
java.lang.Object
|
+----com.ibm.db.StatementMetaData
- public class StatementMetaData
- extends Object
- implements Serializable
StatementMetaData represents a SQL statement and associated
metadata about the SQL statement.
Part of the metadata is the mapping between the SQLType of data in database and the
Java class that will be used to represent the data. The default mapping is:
Default Mapping |
SQLType | Java Class |
CHAR | java.lang.String |
VARCHAR | java.lang.String |
LONGVARCHAR | java.lang.String |
TINYINT | java.lang.Integer |
SMALLINT | java.lang.Short |
BIGINT | java.lang.Integer |
INTEGER | java.lang.Integer |
DECIMAL | java.math.BigDecimal |
NUMERIC | java.math.BigDecimal |
REAL | java.lang.Float |
FLOAT | java.lang.Double |
DOUBLE | java.lang.Double |
BINARY | byte[] |
VARBINARY | byte[] |
LONGVARBINARY | byte[] |
DATE | java.sql.Date |
TIME | java.sql.Time |
TIMESTAMP | java.sql.Timestamp |
- Version:
- 1.0 06/30/98
- See Also:
- Statement
Constructor Index
- StatementMetaData()
- Constructs a new StatementMetaData.
Method Index
- addColumn(String, Class, int)
- Defines a new column with the given name whose value can be passed as an instance
of the specified java class, and whose SQL type is the specified value.
- addColumn(String, int, int)
- Defines a new column with the given name.
- addParameter(String, Class, int)
- Defines a new parameter with the given name whose value can be passed as an instance
of the specified java class, and whose SQL type is the specified value.
- addParameter(String, int, int)
- Defines a new parameter with the given name and the specified SQLType.
- addTable(String)
- Defines a table name that is used in this SQL statement.
- getColumnClass(int)
- Returns the java class that is used for the values of the column.
- getColumnClass(String)
- Returns the java class that is used for the values of the column.
- getColumnCount()
- Returns the number of columns in the result set.
- getColumnIndex(String)
- Returns the index of the column based on its name.
- getColumnLength(int)
- Returns the length of the indexed column.
- getColumnLength(String)
- Returns the length of the named column.
- getColumnName(int)
- Returns the name of the specified column.
- getColumnNames()
- Returns an enumeration of the column names.
- getColumnScale(int)
- Returns the scale of the indexed column.
- getColumnScale(String)
- Returns the scale of the indexed column.
- getColumnSQLType(int)
- Returns the SQLType of the column in the database.
- getColumnSQLType(String)
- Returns the SQLType of the named column.
- getName()
- Returns the name associated with this StatementMetaData.
- getParameterClass(int)
- Returns the java class that is used for the value of the parameter.
- getParameterClass(String)
- Returns the java class that is used for the value of the parameter.
- getParameterCount()
- Returns the number of parameters that have been defined for this SQL statement.
- getParameterIndex(String)
- Returns the index of the parameter based on its name.
- getParameterLength(int)
- Returns the length of the specified parameter.
- getParameterLength(String)
- Returns the length of the specified parameter.
- getParameterName(int)
- Returns the name of the specified parameter.
- getParameterScale(int)
- Returns the scale of the specified parameter.
- getParameterScale(String)
- Returns the scale of the specified parameter.
- getParameterSQLType(int)
- Returns the SQLType of the specified parameter.
- getParameterSQLType(String)
- Returns the SQLType of the specified parameter.
- getSQL()
- Returns the SQL statement for this StatementMetadata.
- getTables()
- Returns an enumeration of tables for this SQL statement.
- removeColumn(int)
- Removes the column from the list of defined columns.
- removeColumn(String)
- Removes the column from the list of defined columns.
- removeParameter(int)
- Removes the parameter from the list of defined parameters.
- removeParameter(String)
- Removes the parameter from the list of defined parameters.
- removeTable(String)
- Removes the table from the list of defined tables.
- setColumnLength(int, int)
- Sets a user-defined length for the specified column.
- setColumnLength(String, int)
- Sets a user-defined length for the specified column.
- setColumnScale(int, int)
- Sets a user-defined scale for the specified column.
- setColumnScale(String, int)
- Sets a user-defined scale for the specified column.
- setColumnSQLType(int, int)
- Sets the SQLType of the specified column.
- setColumnSQLType(String, int)
- Sets the SQLType of the specified column.
- setName(String)
- Sets the name for this StatementMetaData.
- setParameterLength(int, int)
- Sets a user-defined length for the specified parameter.
- setParameterLength(String, int)
- Sets a user-defined length for the specified parameter.
- setParameterScale(int, int)
- Sets a user-defined scale for the specified parameter.
- setParameterScale(String, int)
- Sets a user-defined scale for the specified parameter.
- setParameterSQLType(int, int)
- Sets the SQLType for the specified parameter.
- setParameterSQLType(String, int)
- Sets the SQLType for the specified parameter.
- setSQL(String)
- Sets the SQL statement for this StatementMetadata.
Constructors
StatementMetaData
public StatementMetaData()
- Constructs a new StatementMetaData.
Methods
addColumn
public void addColumn(String columnName,
int targetSQLType,
int sourceSQLType) throws DataException
- Defines a new column with the given name. The index of the defined column is determined by
the order in which the columns were defined. The first defined column has an index
of 1.
As part of the definition, you define the SQLtype of the column in the database, as
well as the SQLType to which you want to convert the data. Base on the targetSQLType,
the data will be retrieved into a appropriate Java class, as specified in the Default
Mapping Table.
- Parameters:
- columnName - the name of the column
- targetSQLType - the SQLtype that the column will be treated as
- sourceSQLType - the SQLtype of the column in the database.
- Throws: DataException
- if the SQLtype is invalid or unsupported
- Throws: DataException
- if the column name is a duplicate of an existing column
- See Also:
- removeColumn
addColumn
public void addColumn(String columnName,
Class javaClass,
int sourceSQLType) throws DataException
- Defines a new column with the given name whose value can be passed as an instance
of the specified java class, and whose SQL type is the specified value.
The index of the defined column is determined by the order in which the columns were defined.
The first defined column has an index of 1.
Use the class literal syntax "xxx.class" to get an instance of a java class to pass as
the second parameter, where "xxx" is the name you would code, for example "boolean.class"
or "String.class".
- Parameters:
- columnName - the name of the column
- javaClass - the java class for the column
- sourceSQLType - the SQLtype of the column in the database.
- Throws: DataException
- if the javaClass parameter is null
- Throws: DataException
- if the SQLtype is invalid or unsupported
- Throws: DataException
- if the column name is a duplicate of an existing column
- See Also:
- removeColumn
addParameter
public void addParameter(String parameterName,
int targetSQLType,
int sourceSQLType) throws DataException
- Defines a new parameter with the given name and the specified SQLType. The index of the defined
parameter is determined by the order in which the parameters were defined. The first defined
parameter has an index of 1.
As part of the definition, you define the SQLtype of the parameter in the database, as
well as the SQLType to which you want to convert the data. Base on the targetSQLType,
the data will be retrieved into a appropriate Java class, as specified in the Default
Mapping Table.
- Parameters:
- parameterName - the name of the parameter
- targetSQLType - the SQLtype that the parameter will be treated as
- sourceSQLType - the SQLtype of the parameter in the database.
- Throws: DataException
- if the SQLtype is invalid or unsupported
- Throws: DataException
- if the parameter name is a duplicate of an existing
parameter
- See Also:
- removeParameter
addParameter
public void addParameter(String name,
Class javaClass,
int sourceSQLType) throws DataException
- Defines a new parameter with the given name whose value can be passed as an instance
of the specified java class, and whose SQL type is the specified value.
The index of the defined parameter is determined by the order in which the parameters were defined.
The first defined parameter has an index of 1.
Use the class literal syntax "xxx.class" to get an instance of a java class to pass as
the second parameter, where "xxx" is the name you would code, for example "boolean.class"
or "String.class".
- Parameters:
- parameterName - the name of the parameter
- sourceSQLType - the SQLtype of the parameter
- Throws: DataException
- if the SQLtype is invalid or unsupported
- Throws: DataException
- if the parameter name is a duplicate of an existing
parameter
- See Also:
- removeParameter
addTable
public void addTable(String tableName)
- Defines a table name that is used in this SQL statement.
- Parameters:
- tableName - the table name
- See Also:
- removeTable
getColumnClass
public Class getColumnClass(int columnNumber)
- Returns the java class that is used for the values of the column. If the columns have been
defined by
addColumn
, this method returns the java class used in the definition.
If the columns have not been defined by addColumn
, the java class is not available
until after the SQL statement has been executed.
- Parameters:
- columnNumber - the index of the column
- Returns:
- the java class for the column
- Throws: IndexOutOfBoundsException
- if the column index is not defined
getColumnClass
public Class getColumnClass(String columnName)
- Returns the java class that is used for the values of the column. If the columns have been
defined by
addColumn
, this method returns the java class used in the definition.
If the columns have not been defined by addColumn
, the java class is not available
until after the SQL statement has been executed.
- Parameters:
- columnName - the name of the column
- Returns:
- the java class for the column
- Throws: IndexOutOfBoundsException
- if the column name is not defined
getColumnCount
public int getColumnCount()
- Returns the number of columns in the result set. If the columns have been
defined by
addColumn
, this method returns the number of columns that have
currently been defined. If the columns have not been defined by addColumn
, the number
of columns is not available until after the SQL statement has been executed.
- Returns:
- the number of columns
getColumnIndex
public int getColumnIndex(String columnName)
- Returns the index of the column based on its name. If the columns have been
defined by
addColumn
, this method returns an index representing the order
that the columns were defined. If the columns have not been defined by addColumn
,
the column index is not available until after the SQL statement has been executed. The first
defined column has an index of 1.
- Parameters:
- columnName - the name of the column
- Returns:
- the column index
getColumnLength
public int getColumnLength(int columnNumber)
- Returns the length of the indexed column. If the columns have not been defined by
addColumn
, the length is not available until after the SQL statement has been executed.
- Parameters:
- columnNumber - the index of the column
- Returns:
- the column length
- Throws: IndexOutOfBoundsException
- if the column index is not defined
- See Also:
- setColumnLength
getColumnLength
public int getColumnLength(String columnName)
- Returns the length of the named column. If the columns have not been defined by
addColumn
, the length is not available until after the SQL statement has been executed.
- Parameters:
- columnName - the name of the column
- Returns:
- the column length
- Throws: IndexOutOfBoundsException
- if the column name is not defined
- See Also:
- setColumnLength
getColumnName
public String getColumnName(int columnNumber)
- Returns the name of the specified column. If the columns have not been defined by
addColumn
, the name is not available until after the SQL statement has been executed.
- Parameters:
- columnNumber - the index of the column
- Returns:
- the column name
- Throws: IndexOutOfBoundsException
- if the column index is not defined
getColumnNames
public Enumeration getColumnNames()
- Returns an enumeration of the column names. If the columns have been defined by
addColumn
, this method returns the names of columns that have currently been defined.
If the columns have not been defined by addColumn
, the names of the columns
are not available until after the SQL statement has been executed.
- Returns:
- the column names
getColumnScale
public int getColumnScale(int columnNumber)
- Returns the scale of the indexed column. If the columns have not been defined by
addColumn
, the scale is not available until after the SQL statement has been executed.
- Parameters:
- columnNumber - the index of the column
- Returns:
- the column scale
- Throws: IndexOutOfBoundsException
- if the column index is not defined
- See Also:
- setColumnScale
getColumnScale
public int getColumnScale(String columnName)
- Returns the scale of the indexed column. If the columns have not been defined by
addColumn
, the scale is not available until after the SQL statement has been executed.
- Parameters:
- columnName - the name of the column
- Returns:
- the column scale
- Throws: IndexOutOfBoundsException
- if the column name is not defined
- See Also:
- setColumnScale
getColumnSQLType
public int getColumnSQLType(int columnNumber)
- Returns the SQLType of the column in the database. If the columns have not been defined by
addColumn
, the SQLType is not available until after the SQL statement has been executed.
- Parameters:
- columnNumber - the index of the column
- Returns:
- the column SQLType
- Throws: IndexOutOfBoundsException
- if the column index is not defined
- See Also:
- setColumnSQLType
getColumnSQLType
public int getColumnSQLType(String columnName)
- Returns the SQLType of the named column. If the columns have not been defined by
addColumn
, the SQLType is not available until after the SQL statement has been executed.
- Parameters:
- columnName - the name of the column
- Returns:
- the column SQLType
- Throws: IndexOutOfBoundsException
- if the column index is not defined
- See Also:
- setColumnSQLType
getName
public String getName()
- Returns the name associated with this StatementMetaData.
- Returns:
- the name of this StatementMetaData
- See Also:
- setName
getParameterClass
public Class getParameterClass(int parameterNumber)
- Returns the java class that is used for the value of the parameter.
- Parameters:
- parameterNumber - the index of the parameter
- Returns:
- the java class for the parameter
- Throws: IndexOutOfBoundsException
- if the parameter index is not defined
getParameterClass
public Class getParameterClass(String parameterName)
- Returns the java class that is used for the value of the parameter.
- Parameters:
- parameterName - the name of the parameter
- Returns:
- the java class for the parameter
- Throws: IndexOutOfBoundsException
- if the parameter name is not defined
getParameterCount
public int getParameterCount()
- Returns the number of parameters that have been defined for this SQL statement.
- Returns:
- the number of parameters
getParameterIndex
public int getParameterIndex(String parameterName)
- Returns the index of the parameter based on its name. The first defined parameter has an
index of 1.
- Parameters:
- parameterName - the name of the parameter
- Returns:
- the parameter index
- Throws: IndexOutOfBoundsException
- if the parameter name is not defined
getParameterLength
public int getParameterLength(int parameterNumber)
- Returns the length of the specified parameter.
- Parameters:
- parameterNumber - the index of the parameter
- Returns:
- the parameter length
- Throws: IndexOutOfBoundsException
- if the parameter index is not defined
- See Also:
- setParameterLength
getParameterLength
public int getParameterLength(String parameterName)
- Returns the length of the specified parameter.
- Parameters:
- parameterName - the name of the parameter
- Returns:
- the parameter length
- Throws: IndexOutOfBoundsException
- if the parameter name is not defined
- See Also:
- setParameterLength
getParameterName
public String getParameterName(int parameterNumber)
- Returns the name of the specified parameter.
- Parameters:
- parameterNumber - the index of the parameter
- Returns:
- the parameter name
- Throws: IndexOutOfBoundsException
- if the parameter index is not defined
getParameterScale
public int getParameterScale(int parameterNumber)
- Returns the scale of the specified parameter.
- Parameters:
- parameterNumber - the index of the parameter
- Returns:
- the parameter scale
- Throws: IndexOutOfBoundsException
- if the parameter index is not defined
- See Also:
- setParameterScale
getParameterScale
public int getParameterScale(String parameterName)
- Returns the scale of the specified parameter.
- Parameters:
- parameterName - the name of the parameter
- Returns:
- the parameter scale
- Throws: IndexOutOfBoundsException
- if the parameter name is not defined
- See Also:
- setParameterScale
getParameterSQLType
public int getParameterSQLType(int parameterNumber)
- Returns the SQLType of the specified parameter.
- Parameters:
- parameterNumber - the index of the parameter
- Returns:
- the parameter SQLType
- Throws: IndexOutOfBoundsException
- if the parameter index is not defined
- See Also:
- setParameterSQLType
getParameterSQLType
public int getParameterSQLType(String parameterName)
- Returns the SQLType of the specified parameter.
- Parameters:
- parameterName - the name of the parameter
- Returns:
- the parameter SQLType
- Throws: IndexOutOfBoundsException
- if the parameter name is not defined
- See Also:
- setParameterSQLType
getSQL
public String getSQL()
- Returns the SQL statement for this StatementMetadata.
- Returns:
- the SQL statement
- See Also:
- DatabaseQuerySpec, setSQL
getTables
public Enumeration getTables()
- Returns an enumeration of tables for this SQL statement.
- Returns:
- an enumeration of tables for this statement
removeColumn
public void removeColumn(int columnNumber)
- Removes the column from the list of defined columns. The indexes of any columns
after this one are decremented by 1.
- Parameters:
- columnNumber - the index of the column
- Throws: IndexOutOfBoundsException
- if the column index is not defined
- See Also:
- addColumn
removeColumn
public void removeColumn(String columnName)
- Removes the column from the list of defined columns. The indexes of any columns
after this one are decremented by 1.
- Parameters:
- columnName - the name of the column
- Throws: IndexOutOfBoundsException
- if the column name is not defined
- See Also:
- addColumn
removeParameter
public void removeParameter(int parameterNumber)
- Removes the parameter from the list of defined parameters. The indexes of any
parameters after this one are decremented by 1.
- Parameters:
- parameterNumber - the index of the parameter
- Throws: IndexOutOfBoundsException
- if the parameter index is not defined
- See Also:
- addParameter
removeParameter
public void removeParameter(String parameterName)
- Removes the parameter from the list of defined parameters. The indexes of any
parameters after this one are decremented by 1.
- Parameters:
- parameterName - the name of the parameter
- Throws: IndexOutOfBoundsException
- if the parameter name is not defined
- See Also:
- addParameter
removeTable
public void removeTable(String tableName) throws DataException
- Removes the table from the list of defined tables.
- Parameters:
- tableName - the table name
- Throws: DataException
- if the table name is not defined
- See Also:
- addTable
setColumnLength
public void setColumnLength(int columnNumber,
int definedLength) throws DataException
- Sets a user-defined length for the specified column. This method should only be used
if the column was defined by
addColumn
. Otherwise the column length will be
obtained from the database when the columns are described after the SQL statement has been
executed.
- Parameters:
- columnNumber - the index of the column
- definedLength - the length of the column
- Throws: IndexOutOfBoundsException
- if the column index is not defined
- See Also:
- getColumnLength
setColumnLength
public void setColumnLength(String columnName,
int definedLength) throws DataException
- Sets a user-defined length for the specified column. This method should only be used
if the column was defined by
addColumn
. Otherwise the column length will be
obtained from the database when the columns are described after the SQL statement has been
executed.
- Parameters:
- columnName - the name of the column
- definedLength - the length of the column
- Throws: IndexOutOfBoundsException
- if the column name is not defined
- See Also:
- getColumnLength
setColumnScale
public void setColumnScale(int columnNumber,
int definedScale) throws DataException
- Sets a user-defined scale for the specified column. This method should only be used
if the column was defined by
addColumn
. Otherwise the column scale will be
obtained from the database when the columns are described after the SQL statement has been
executed.
- Parameters:
- columnNumber - the index of the column
- definedScale - the scale of the column
- Throws: IndexOutOfBoundsException
- if the column index is not defined
- See Also:
- getColumnScale
setColumnScale
public void setColumnScale(String columnName,
int definedScale) throws DataException
- Sets a user-defined scale for the specified column. This method should only be used
if the column was defined by
addColumn
. Otherwise the column scale will be
obtained from the database when the columns are described after the SQL statement has been
executed.
- Parameters:
- columnName - the name of the column
- definedScale - the scale of the column
- Throws: IndexOutOfBoundsException
- if the column name is not defined
- See Also:
- getColumnScale
setColumnSQLType
public void setColumnSQLType(int columnNumber,
int type)
- Sets the SQLType of the specified column. This method should only be used
if the column was defined by
addColumn
. Otherwise the column SQLType will be
obtained from the database when the columns are described after the SQL statement has been
executed.
- Parameters:
- columnNumber - the index of the column
- type - the SQLType of the column
- Throws: IndexOutOfBoundsException
- if the column index is not defined
- See Also:
- getColumnSQLType
setColumnSQLType
public void setColumnSQLType(String columnName,
int type)
- Sets the SQLType of the specified column. This method should only be used
if the column was defined by
addColumn
. Otherwise the column SQLType will be
obtained from the database when the columns are described after the SQL statement has been
executed.
- Parameters:
- columnName - the name of the column
- type - the SQLType of the column
- Throws: IndexOutOfBoundsException
- if the column name is not defined
- See Also:
- getColumnSQLType
setName
public void setName(String name)
- Sets the name for this StatementMetaData.
- Parameters:
- name - the name of thsi StatementMetaData
- See Also:
- getName
setParameterLength
public void setParameterLength(int parameterNumber,
int definedLength) throws DataException
- Sets a user-defined length for the specified parameter.
- Parameters:
- parameterNumber - the index of the parameter
- definedLength - the length of the parameter
- Throws: IndexOutOfBoundsException
- if the parameter index is not defined
- See Also:
- getParameterLength
setParameterLength
public void setParameterLength(String parameterName,
int definedLength) throws DataException
- Sets a user-defined length for the specified parameter.
- Parameters:
- parameterName - the name of the parameter
- definedLength - the length of the parameter
- Throws: IndexOutOfBoundsException
- if the parameter name is not defined
- See Also:
- getParameterLength
setParameterScale
public void setParameterScale(int parameterNumber,
int definedScale) throws DataException
- Sets a user-defined scale for the specified parameter.
- Parameters:
- parameterNumber - the index of the parameter
- definedScale - the scale of the parameter
- Throws: IndexOutOfBoundsException
- if the parameter index is not defined
- See Also:
- getParameterScale
setParameterScale
public void setParameterScale(String parameterName,
int definedScale) throws DataException
- Sets a user-defined scale for the specified parameter.
- Parameters:
- parameterName - the name of the parameter
- definedScale - the scale of the parameter
- Throws: IndexOutOfBoundsException
- if the parameter name is not defined
- See Also:
- getParameterScale
setParameterSQLType
public void setParameterSQLType(int parameterNumber,
int type)
- Sets the SQLType for the specified parameter.
- Parameters:
- parameterNumber - the index of the parameter
- type - the SQLType of the parameter
- Throws: IndexOutOfBoundsException
- if the parameter index is not defined
- See Also:
- getParameterSQLType
setParameterSQLType
public void setParameterSQLType(String parameterName,
int type)
- Sets the SQLType for the specified parameter.
- Parameters:
- parameterName - the name of the parameter
- type - the SQLType of the parameter
- Throws: IndexOutOfBoundsException
- if the parameter name is not defined
- See Also:
- getParameterSQLType
setSQL
public void setSQL(String aStatement)
- Sets the SQL statement for this StatementMetadata.
- Parameters:
- sStatement - the SQL statement
- See Also:
- getSQL
