|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.db.StatementMetaData
StatementMetaData represents a SQL statement and associated metadata about the SQL statement, including the actual text of the SQL statement, descriptions of any result columns and any parameters, and a list of the tables referenced in the SQL statement.
For both result columns and parameters, the descriptions include the name and number of the column or parameter, its SQL data type in the database, and the java class your program will use to handle the value. When you add a column or parameter description, you can either explicitly name the java class you want to use, or you can specify an SQL data type that you want the column or parameter treated as. The method will then describe the column or parameter as using the default java class for that SQL data type.
The default mapping of SQL data types to java classes 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.Long |
INTEGER | java.lang.Integer |
BIT | java.lang.Boolean |
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 |
CLOB | java.sql.Clob |
BLOB | java.sql.Blob |
StatementMetaData objects can be chained. This allows you to specify multiple StatementMetaData objects for a CallableStatement. For a CallableStatement, the first StatementMetaData object describes the CALL statement that executes the stored procedure, including any parameters used for input and/or output. Any StatementMetaData objects chained behind the first one describe result sets that the stored procedure returns.
Statement
, Serialized FormField Summary | |
private static java.lang.String |
copyright
|
protected Statement |
fieldStatement
|
protected StatementMetaData |
nextMetaData
|
static int |
PARM_MODE_INOUT
|
static int |
PARM_MODE_INPUT
|
static int |
PARM_MODE_OUTPUT
|
protected DatabaseQuerySpec |
querySpec
|
(package private) static long |
serialVersionUID
|
protected java.util.Vector |
tables
|
Constructor Summary | |
|
StatementMetaData()
Constructs a new StatementMetaData. |
protected |
StatementMetaData(DatabaseQuerySpec aSpec)
Constructs a new StatementMetaData and associates it with the specified DatabaseQuerySpec. |
Method Summary | |
void |
addColumn(java.lang.String columnName,
java.lang.Class javaClass,
int sourceSQLType)
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. |
void |
addColumn(java.lang.String columnName,
int targetSQLType,
int sourceSQLType)
Defines a new column with the given name. |
void |
addParameter(java.lang.String name,
java.lang.Class javaClass,
int sourceSQLType)
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. |
void |
addParameter(java.lang.String parameterName,
java.lang.Class javaClass,
int sourceSQLType,
int mode)
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. |
void |
addParameter(java.lang.String parameterName,
int targetSQLType,
int sourceSQLType)
Defines a new parameter with the given name and the specified SQLType. |
void |
addParameter(java.lang.String parameterName,
int targetSQLType,
int sourceSQLType,
int mode)
Defines a new parameter with the given name and the specified SQLType. |
void |
addTable(java.lang.String tableName)
Defines a table name that is used in this SQL statement. |
java.lang.Class |
getColumnClass(int columnNumber)
Returns the java class that is used for the values of the column. |
java.lang.Class |
getColumnClass(java.lang.String columnName)
Returns the java class that is used for the values of the column. |
int |
getColumnCount()
Returns the number of columns in the result set. |
int |
getColumnIndex(java.lang.String columnName)
Returns the index of the column based on its name. |
int |
getColumnLength(int columnNumber)
Returns the length of the indexed column. |
int |
getColumnLength(java.lang.String columnName)
Returns the length of the named column. |
java.lang.String |
getColumnName(int columnNumber)
Returns the name of the specified column. |
java.util.Enumeration |
getColumnNames()
Returns an enumeration of the column names. |
int |
getColumnScale(int columnNumber)
Returns the scale of the indexed column. |
int |
getColumnScale(java.lang.String columnName)
Returns the scale of the indexed column. |
protected DatabaseCompoundType |
getColumnShape()
Returns a DatabaseCompoundType describing the result columns in the SQL statement. |
int |
getColumnSQLType(int columnNumber)
Returns the SQLType of the column in the database. |
int |
getColumnSQLType(java.lang.String columnName)
Returns the SQLType of the named column. |
protected java.lang.String |
getColumnSQLTypeName(int columnNumber)
Returns the name of the SQL type of the column in the database. |
protected DatabaseTypeField |
getColumnType(int columnNumber)
Returns a DatabaseTypeField that describes the specified column. |
protected DatabaseQuerySpec |
getDbQuerySpec()
Returns the DatabaseQuerySpec that is associated with the StatementMetaData. |
java.lang.String |
getName()
Returns the name associated with this StatementMetaData. |
StatementMetaData |
getNextMetaData()
Returns the next chained StatementMetaData, or null if this is the final StatementMetaData. |
java.lang.Class |
getParameterClass(int parameterNumber)
Returns the java class that is used for the value of the parameter. |
java.lang.Class |
getParameterClass(java.lang.String parameterName)
Returns the java class that is used for the value of the parameter. |
int |
getParameterCount()
Returns the number of parameters that have been defined for this SQL statement. |
int |
getParameterIndex(java.lang.String parameterName)
Returns the index of the parameter based on its name. |
int |
getParameterLength(int parameterNumber)
Returns the length of the specified parameter. |
int |
getParameterLength(java.lang.String parameterName)
Returns the length of the specified parameter. |
int |
getParameterMode(int parameterNumber)
Returns the mode of the specified parameter. |
int |
getParameterMode(java.lang.String parameterName)
Returns the mode of the specified parameter. |
java.lang.String |
getParameterName(int parameterNumber)
Returns the name of the specified parameter. |
int |
getParameterScale(int parameterNumber)
Returns the scale of the specified parameter. |
int |
getParameterScale(java.lang.String parameterName)
Returns the scale of the specified parameter. |
protected DatabaseCompoundType |
getParameterShape()
Returns a DatabaseCompoundType describing the parameters. |
int |
getParameterSQLType(int parameterNumber)
Returns the SQLType of the specified parameter. |
int |
getParameterSQLType(java.lang.String parameterName)
Returns the SQLType of the specified parameter. |
protected DatabaseTypeField |
getParameterType(int parameterNumber)
Returns a DatabaseTypeField that describes the specified parameter. |
java.lang.String |
getSQL()
Returns the SQL statement for this StatementMetadata. |
java.util.Enumeration |
getTables()
Returns an enumeration of tables for this SQL statement. |
void |
removeColumn(int columnNumber)
Removes the column from the list of defined columns. |
void |
removeColumn(java.lang.String columnName)
Removes the column from the list of defined columns. |
void |
removeParameter(int parameterNumber)
Removes the parameter from the list of defined parameters. |
void |
removeParameter(java.lang.String parameterName)
Removes the parameter from the list of defined parameters. |
void |
removeTable(java.lang.String tableName)
Removes the table from the list of defined tables. |
void |
setColumnLength(int columnNumber,
int definedLength)
Sets a user-defined length for the specified column. |
void |
setColumnLength(java.lang.String columnName,
int definedLength)
Sets a user-defined length for the specified column. |
void |
setColumnScale(int columnNumber,
int definedScale)
Sets a user-defined scale for the specified column. |
void |
setColumnScale(java.lang.String columnName,
int definedScale)
Sets a user-defined scale for the specified column. |
protected void |
setColumnShape(DatabaseCompoundType aType)
Sets the column shape to the specified DatabaseCompoundType. |
void |
setColumnSQLType(int columnNumber,
int type)
Sets the SQLType of the specified column. |
void |
setColumnSQLType(java.lang.String columnName,
int type)
Sets the SQLType of the specified column. |
void |
setName(java.lang.String name)
Sets the name for this StatementMetaData. |
void |
setNextMetaData(StatementMetaData aMetaData)
Chains the specified StatementMetaData after this one. |
void |
setParameterLength(int parameterNumber,
int definedLength)
Sets a user-defined length for the specified parameter. |
void |
setParameterLength(java.lang.String parameterName,
int definedLength)
Sets a user-defined length for the specified parameter. |
void |
setParameterMode(int parameterNumber,
int aMode)
Sets a mode for the specified parameter. |
void |
setParameterMode(java.lang.String parameterName,
int aMode)
Sets a mode for the specified parameter. |
void |
setParameterScale(int parameterNumber,
int definedScale)
Sets a user-defined scale for the specified parameter. |
void |
setParameterScale(java.lang.String parameterName,
int definedScale)
Sets a user-defined scale for the specified parameter. |
void |
setParameterSQLType(int parameterNumber,
int type)
Sets the SQLType for the specified parameter. |
void |
setParameterSQLType(java.lang.String parameterName,
int type)
Sets the SQLType for the specified parameter. |
void |
setSQL(java.lang.String aStatement)
Sets the SQL statement for this StatementMetadata. |
protected void |
setStatement(Statement statement)
Associates a Statement with this StatementMetaData. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected DatabaseQuerySpec querySpec
protected java.util.Vector tables
protected StatementMetaData nextMetaData
protected Statement fieldStatement
public static final int PARM_MODE_INPUT
public static final int PARM_MODE_INOUT
public static final int PARM_MODE_OUTPUT
static final long serialVersionUID
private static final java.lang.String copyright
Constructor Detail |
public StatementMetaData()
protected StatementMetaData(DatabaseQuerySpec aSpec)
aSpec
- the query specification.Method Detail |
public void addColumn(java.lang.String columnName, int targetSQLType, int sourceSQLType) throws DataException
As part of the definition, you define the SQL data type of the column in the database, as well as the SQL data type you want the data treated as. The data will be retrieved into the default java class for the SQL type you want the data treated as. The default java class for each SQL data type is shown in the default mapping table in the overview documentation of the StatementMetaData class itself.
columnName
- the name of the columntargetSQLType
- the SQLtype that the column will be treated assourceSQLType
- the SQLtype of the column in the databaseremoveColumn(int)
public void addColumn(java.lang.String columnName, java.lang.Class javaClass, int sourceSQLType) throws DataException
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
.
The default java class for each SQL data type is shown in the default mapping table in the overview documentation of the StatementMetaData class itself.
columnName
- the name of the columnjavaClass
- the java class for the columnsourceSQLType
- the SQLtype of the column in the databaseremoveColumn(int)
public void addParameter(java.lang.String parameterName, int targetSQLType, int sourceSQLType) throws DataException
As part of the definition, you define the SQL data type of the parameter in the database, as well as the SQL data type you want the data treated as. The data will be stored in the default java class for the SQL type you want the data treated as. The default java class for each SQL data type is shown in the default mapping table in the overview documentation of the StatementMetaData class itself.
parameterName
- the name of the parametertargetSQLType
- the SQLtype that the parameter will be treated assourceSQLType
- the SQLtype of the parameter in the database.mode
- the use of the parameter for input, output, or bothremoveParameter(int)
public void addParameter(java.lang.String parameterName, int targetSQLType, int sourceSQLType, int mode) throws DataException
As part of the definition, you define the SQL data type of the parameter in the database, as well as the SQL data type you want the data treated as. The data will be stored in the default java class for the SQL type you want the data treated as. The default java class for each SQL data type is shown in the default mapping table in the overview documentation of the StatementMetaData class itself.
parameterName
- the name of the parametertargetSQLType
- the SQLtype that the parameter will be treated assourceSQLType
- the SQLtype of the parameter in the database.mode
- the use of the parameter for input, output, or bothremoveParameter(int)
public void addParameter(java.lang.String name, java.lang.Class javaClass, int sourceSQLType) throws DataException
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
.
The default java class for each SQL data type is shown in the default mapping table in the overview documentation of the StatementMetaData class itself.
parameterName
- the name of the parameterjavaClass
- the java class to use for input and output of the parameter valuesourceSQLType
- the SQLtype of the parameterremoveParameter(int)
public void addParameter(java.lang.String parameterName, java.lang.Class javaClass, int sourceSQLType, int mode) throws DataException
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
.
The default java class for each SQL data type is shown in the default mapping table in the overview documentation of the StatementMetaData class itself.
parameterName
- the name of the parameterjavaClass
- the java class to use for input and output of the parameter valuesourceSQLType
- the SQLtype of the parametermode
- the use of the parameter for input, output, or bothremoveParameter(int)
public void addTable(java.lang.String tableName)
tableName
- the table nameremoveTable(java.lang.String)
public java.lang.Class getColumnClass(int columnNumber)
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.columnNumber
- the index of the columnpublic java.lang.Class getColumnClass(java.lang.String columnName)
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.columnName
- the name of the columnpublic int getColumnCount()
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.public int getColumnIndex(java.lang.String columnName)
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.columnName
- the name of the columnpublic int getColumnLength(int columnNumber)
addColumn
, the length is not available until after the SQL statement has been executed.columnNumber
- the index of the columnsetColumnLength(int, int)
public int getColumnLength(java.lang.String columnName)
addColumn
, the length is not available until after the SQL statement has been executed.columnName
- the name of the columnsetColumnLength(int, int)
public java.lang.String getColumnName(int columnNumber)
addColumn
, the name is not available until after the SQL statement has been executed.columnNumber
- the index of the columnpublic java.util.Enumeration getColumnNames()
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.public int getColumnScale(int columnNumber)
addColumn
, the scale is not available until after the SQL statement has been executed.columnNumber
- the index of the columnsetColumnScale(int, int)
public int getColumnScale(java.lang.String columnName)
addColumn
, the scale is not available until after the SQL statement has been executed.columnName
- the name of the columnsetColumnScale(int, int)
protected DatabaseCompoundType getColumnShape()
setColumnShape(com.ibm.db.base.DatabaseCompoundType)
public int getColumnSQLType(int columnNumber)
addColumn
, the SQLType is not available until after the SQL statement has been executed.columnNumber
- the index of the columnsetColumnSQLType(int, int)
public int getColumnSQLType(java.lang.String columnName)
addColumn
, the SQLType is not available until after the SQL statement has been executed.columnName
- the name of the columnsetColumnSQLType(int, int)
protected java.lang.String getColumnSQLTypeName(int columnNumber)
columnNumber
- the index of the column#setColumnSQLTypeName
protected DatabaseTypeField getColumnType(int columnNumber)
addColumn
, the column description is not available until after the
SQL statement has been executed.columnNumber
- the index of the columnprotected DatabaseQuerySpec getDbQuerySpec()
#setDbQuerySpec
public java.lang.String getName()
setName(java.lang.String)
public StatementMetaData getNextMetaData()
setNextMetaData(com.ibm.db.StatementMetaData)
public java.lang.Class getParameterClass(int parameterNumber)
parameterNumber
- the index of the parameterpublic java.lang.Class getParameterClass(java.lang.String parameterName)
parameterName
- the name of the parameterpublic int getParameterCount()
public int getParameterIndex(java.lang.String parameterName)
parameterName
- the name of the parameterpublic int getParameterLength(int parameterNumber)
parameterNumber
- the index of the parametersetParameterLength(int, int)
public int getParameterLength(java.lang.String parameterName)
parameterName
- the name of the parametersetParameterLength(int, int)
public int getParameterMode(int parameterNumber)
parameterNumber
- the index of the parametersetParameterMode(int, int)
public int getParameterMode(java.lang.String parameterName)
parameterName
- the name of the parametersetParameterMode(int, int)
public java.lang.String getParameterName(int parameterNumber)
parameterNumber
- the index of the parameterpublic int getParameterScale(int parameterNumber)
parameterNumber
- the index of the parametersetParameterScale(int, int)
public int getParameterScale(java.lang.String parameterName)
parameterName
- the name of the parametersetParameterScale(int, int)
protected DatabaseCompoundType getParameterShape()
public int getParameterSQLType(int parameterNumber)
parameterNumber
- the index of the parametersetParameterSQLType(int, int)
public int getParameterSQLType(java.lang.String parameterName)
parameterName
- the name of the parametersetParameterSQLType(int, int)
protected DatabaseTypeField getParameterType(int parameterNumber)
parameterNumber
- the index of the parameterpublic java.lang.String getSQL()
DatabaseQuerySpec
,
setSQL(java.lang.String)
public java.util.Enumeration getTables()
public void removeColumn(int columnNumber)
columnNumber
- the index of the columnaddColumn(java.lang.String, int, int)
public void removeColumn(java.lang.String columnName)
columnName
- the name of the columnaddColumn(java.lang.String, int, int)
public void removeParameter(int parameterNumber)
parameterNumber
- the index of the parameteraddParameter(java.lang.String, int, int)
public void removeParameter(java.lang.String parameterName)
parameterName
- the name of the parameteraddParameter(java.lang.String, int, int)
public void removeTable(java.lang.String tableName) throws DataException
tableName
- the table nameaddTable(java.lang.String)
public void setColumnLength(int columnNumber, int definedLength)
addColumn
. Otherwise the column length will be
obtained from the database when the columns are described after the SQL statement has been
executed.columnNumber
- the index of the columndefinedLength
- the length of the columngetColumnLength(int)
public void setColumnLength(java.lang.String columnName, int definedLength)
addColumn
. Otherwise the column length will be
obtained from the database when the columns are described after the SQL statement has been
executed.columnName
- the name of the columndefinedLength
- the length of the columngetColumnLength(int)
public void setColumnScale(int columnNumber, int definedScale)
addColumn
. Otherwise the column scale will be
obtained from the database when the columns are described after the SQL statement has been
executed.columnNumber
- the index of the columndefinedScale
- the scale of the columngetColumnScale(int)
public void setColumnScale(java.lang.String columnName, int definedScale)
addColumn
. Otherwise the column scale will be
obtained from the database when the columns are described after the SQL statement has been
executed.columnName
- the name of the columndefinedScale
- the scale of the columngetColumnScale(int)
protected void setColumnShape(DatabaseCompoundType aType)
aType
- the description of the columnsgetColumnShape()
,
DatabaseCompoundType
public void setColumnSQLType(int columnNumber, int type)
addColumn
. Otherwise the column SQLType will be
obtained from the database when the columns are described after the SQL statement has been
executed.columnNumber
- the index of the columntype
- the SQLType of the columngetColumnSQLType(int)
public void setColumnSQLType(java.lang.String columnName, int type)
addColumn
. Otherwise the column SQLType will be
obtained from the database when the columns are described after the SQL statement has been
executed.columnName
- the name of the columntype
- the SQLType of the columngetColumnSQLType(int)
public void setName(java.lang.String name)
name
- the name of this StatementMetaDatagetName()
public void setNextMetaData(StatementMetaData aMetaData)
aMetaData
- StatementMetaData to put next in the chaingetNextMetaData()
public void setParameterLength(int parameterNumber, int definedLength)
parameterNumber
- the index of the parameterdefinedLength
- the length of the parametergetParameterLength(int)
public void setParameterLength(java.lang.String parameterName, int definedLength)
parameterName
- the name of the parameterdefinedLength
- the length of the parametergetParameterLength(int)
public void setParameterMode(int parameterNumber, int aMode)
parameterNumber
- the index of the parameteraMode
- the mode of the parameter (PARM_MODE_INPUT, PARM_MODE_OUTPUT, PARM_MODE_INOUT)getParameterMode(int)
public void setParameterMode(java.lang.String parameterName, int aMode)
parameterName
- the name of the parameteraMode
- the mode of the parameter (PARM_MODE_INPUT, PARM_MODE_OUTPUT, PARM_MODE_INOUT)getParameterMode(int)
public void setParameterScale(int parameterNumber, int definedScale)
parameterNumber
- the index of the parameterdefinedScale
- the scale of the parametergetParameterScale(int)
public void setParameterScale(java.lang.String parameterName, int definedScale)
parameterName
- the name of the parameterdefinedScale
- the scale of the parametergetParameterScale(int)
public void setParameterSQLType(int parameterNumber, int type)
parameterNumber
- the index of the parametertype
- the SQLType of the parametergetParameterSQLType(int)
public void setParameterSQLType(java.lang.String parameterName, int type)
parameterName
- the name of the parametertype
- the SQLType of the parametergetParameterSQLType(int)
public void setSQL(java.lang.String aStatement)
sStatement
- the SQL statementgetSQL()
protected void setStatement(Statement statement)
statement
- the associated Statement
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |