|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.db.beans.DBSelectMetaData
This class allows you to get and set meta-data about a result set produced by a DBSelect or DBProcedureCall bean. The meta-data exposes JDBC 2.0 RowSetMetaData functionality and adds its own useful functions.
The java.sql.ResultSetMetaData object allows you to get meta data about a result set after it has been prepared (and possibly executed). The javax.sql.RowSetMetaData object extends that interface by allowing you to set meta data about a result set. The DBSelectMetaData object adds additional function to allow you to specify what java class should be used to store values of a column, to specify the table you plan to update using the result set, to specify which columns should be updatable, and to identify "key" columns in the result set that can be used to uniquely identify a row.
There is no public constructor for DBSelectMetaData. A DBSelect is
created with a DBSelectMetaData, which you can get with
getMetaData()
. A DBProcedureCall is not created with a
DBSelectMetaData, since the stored procedure may not return a result set.
Use DBProcedureCall.createMetaData()
to create one.
You can set meta data before actually executing a statement to change the way your result data will be stored. Or you can simply allow the meta data to be filled in for you after you execute a statement. You can also provide meta data "sparsely", specifing information only for those columns and characteristics which you want to override.
Convenience methods are provided that allow you specify multiple
characteristics at once for a column not previously described.
(setColumn
)
Or, if you want to provide information more sparsely, you can just call
individual methods to set one characteristic of one column at a time.
You can use these same more granular methods to change a description
you have previously provided.
You can describe columns in any order.
The position of the column in the result set is determined by the index
used to call the methods that describe it.
You can also get a reference to the java.sql.ResultSetMetaData which this bean contains and use it to access the full set of methods available on that object.
Method Summary | |
---|---|
void |
clear()
Clears the descriptions of all columns in this result set. |
java.lang.String |
getCatalogName(int column)
Gets the catalog name of the table of the specified column. |
java.lang.Class |
getColumnClass(int column)
Gets the Java class to be used when getting or setting values for this column. |
int |
getColumnCount()
Gets the number of columns in this RowSet. |
java.lang.String |
getColumnLabel(int column)
Gets the label for this column, which may be different from its name. |
java.lang.String |
getColumnName(int column)
Gets a column's name. |
int |
getColumnNumber(java.lang.String name)
Gets the number of a column based on its label. |
int |
getColumnType(int column)
Gets a column's SQL type. |
java.sql.ResultSetMetaData |
getResultSetMetaData()
Gets a reference to the java.sql.ResultSetMetaData object obtained when the associated statement was executed. |
int |
getScale(int column)
Gets the number of digits to the right of the decimal point. |
java.lang.String |
getSchemaName(int column)
Gets the table schema of this column. |
java.lang.String |
getTableForUpdate()
Gets the name of the table to be the target for Update, Insert, and Delete statements generated by the DBSelect bean. |
java.lang.String |
getTableName(int column)
Gets the table name of this column. |
boolean |
isKey(int column)
Indicates whether this column belongs to a set of columns that can uniquely identify a row in the result set. |
boolean |
isUpdateEnabled(int column)
Indicates whether to allow values in this column to be set and then updated in the database using an associated DBSelect or DBProcedureCall. |
boolean |
isWritable(int column)
Indicates whether it is possible to use the associated DBSelect or DBProcedureCall to change database values in this column. |
void |
setCatalogName(int column,
java.lang.String name)
Sets the catalog name of the table of the specified column. |
void |
setColumn(int column,
java.lang.String name,
java.lang.String label,
java.lang.Class aClass,
boolean updateEnabled)
Adds the definition of a new column to this bean. |
void |
setColumnClass(int column,
java.lang.Class aClass)
Sets the Java class to be used when getting or setting values for this column. |
void |
setColumnLabel(int column,
java.lang.String label)
Sets the label for this column, which may be different from its name. |
void |
setColumnName(int column,
java.lang.String aName)
Sets the name for this column. |
void |
setKey(int column,
boolean isKey)
Sets specification of whether this column belongs to a set of columns that can uniquely identify a row in the result set. |
void |
setScale(int column,
int scale)
Sets the number of digits to the right of the decimal point for this column. |
void |
setSchemaName(int column,
java.lang.String name)
Sets the schema name of the table of this column The index of the first column is 1. |
void |
setTableForUpdate(java.lang.String name)
Specifies the name of the table to be the target for Update, Insert, and Delete statements generated by the DBSelect bean. |
void |
setTableName(int column,
java.lang.String name)
Sets the name of the table of this column. |
void |
setUpdateEnabled(int column,
boolean updateEnabled)
Sets specification of whether to allow values in this column to be set and then updated in the database using an associated DBSelect or DBProcedureCall. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public void clear()
setColumn(int, java.lang.String, java.lang.String, java.lang.Class, boolean)
public java.lang.String getCatalogName(int column) throws DBException, java.sql.SQLException
column
- the index of the column
DBException
- columnNotDefined
- if no column has been defined in this position
java.sql.SQLException
- if a database access error occurssetCatalogName(int, java.lang.String)
public java.lang.Class getColumnClass(int column) throws DBException, java.sql.SQLException
column
- the column number
DBException
- columnNotDefined
- if no column has been defined at this position
java.sql.SQLException
- if a database access error occurssetColumnClass(int, java.lang.Class)
public int getColumnCount() throws java.sql.SQLException
java.sql.SQLException
- if a database access error occurspublic java.lang.String getColumnLabel(int column) throws DBException, java.sql.SQLException
If you allow the name and label to be filled in when the statement executes, and the unqualified column name is not unique, the label will be suffixed with a number to make it unique.
In methods of DBSelect and DBProcedureCall that access columns by "name", it is actually the column label that is being matched.
column
- the column number
DBException
- columnNotDefined
- if no column has been defined at this position
java.sql.SQLException
- if a database access error occurssetColumnLabel(int, java.lang.String)
,
getColumnName(int)
public java.lang.String getColumnName(int column) throws DBException, java.sql.SQLException
getTableName
, getSchemaName
,
and getCatalogName
.
In methods of DBSelect and DBProcedureCall that access columns by "name", it is actually the column label that is being matched. (Uniqueness of the label without qualification by table name, etc. is enforced.)
column
- the column number
DBException
- columnNotDefined
- if no column has been defined at this position
java.sql.SQLException
- if a database access error occurssetColumnName(int, java.lang.String)
,
getTableName(int)
,
getSchemaName(int)
,
getCatalogName(int)
,
getColumnLabel(int)
public int getColumnNumber(java.lang.String name) throws DBException
name
- the label of the column
DBException
- columnNotDefined
- if no column has been defined with this labelgetColumnLabel(int)
,
getColumnName(int)
public int getColumnType(int column) throws DBException, java.sql.SQLException
column
- the column number
DBException
- columnNotDefined
- if no column has been defined at this position
java.sql.SQLException
- if a database access error occursTypes
public java.sql.ResultSetMetaData getResultSetMetaData()
public int getScale(int column) throws DBException, java.sql.SQLException
column
- the column number
DBException
- columnNotDefined
- if no column has been defined at this position
java.sql.SQLException
- if a database access error occurssetScale(int, int)
public java.lang.String getSchemaName(int column) throws DBException, java.sql.SQLException
column
- the column number
DBException
- columnNotDefined
- if no column has been defined at this position
java.sql.SQLException
- if a database access error occurssetSchemaName(int, java.lang.String)
public java.lang.String getTableForUpdate()
The name may be the unqualified table name, or may be qualified. It will be substituted exactly as specified into Update, Insert, or Delete statements.
setTableForUpdate(java.lang.String)
public java.lang.String getTableName(int column) throws DBException, java.sql.SQLException
column
- the column number
DBException
- columnNotDefined
- if no column has been defined at this position
java.sql.SQLException
- if a database access error occurssetTableName(int, java.lang.String)
public boolean isKey(int column) throws DBException
If you identify one or more columns as belonging to a "key", when the associated DBSelect or DBProcedureCall bean attempts to locate a row in order to lock it, update it, delete it, etc., it will use the key columns to do so. Otherwise, it will use all of the columns to locate the row, which is a less efficient process.
You may identify one or more columns as the "key" even if no key is actually declared in the database. You should do so only if you are certain that these columns can uniquely identify a row.
column
- the column number
DBException
- columnNotDefined
- if no column has been defined at this positionsetKey(int, boolean)
public boolean isUpdateEnabled(int column) throws DBException, java.sql.SQLException
If this value is false, you will not be allowed to set a value in this column via the associated DBSelect or DBProcedureCall bean even if the associated bean itself is not readOnly.
If this value is true, you will be allowed to set a value in this column via the associated DBSelect or DBProcedureCall as long as the associated bean is not readOnly.
column
- the column number
DBException
- columnNotDefined
- if no column has been defined at this position
java.sql.SQLException
- if a database access error occurssetUpdateEnabled(int, boolean)
,
isWritable(int)
,
DBSelect.isReadOnly()
public boolean isWritable(int column) throws DBException, java.sql.SQLException
This value is true if you have not disabled the setting of values
via the setUpdateEnabled
method and the associated DBSelect or
DBProcedureCall bean is not readOnly, and the database allows writes to
this column.
column
- the column number
DBException
- columnNotDefined
- if no column has been defined at this position
java.sql.SQLException
- if a database access error occurssetUpdateEnabled(int, boolean)
,
DBSelect.isReadOnly()
public void setCatalogName(int column, java.lang.String name) throws DBException, java.sql.SQLException
column
- the column numbername
- the catalog name
DBException
- invalidColumnNumber
- if column number is invalid (less than 1)
java.sql.SQLException
- if a database access error occursgetCatalogName(int)
public void setColumn(int column, java.lang.String name, java.lang.String label, java.lang.Class aClass, boolean updateEnabled) throws DBException, java.sql.SQLException
When you call this method, there must be no column currently defined in the position you specify. The index of the first column is 1.
The characteristics you can specify are those you would specify via the
methods setColumnName
, setColumnLabel
, setColumnClass
,
and setUpdateEnabled
.
column
- the column numbername
- the column name String, may be nulllabel
- the column label String, may be nullaClass
- the java class to be used for column valuesupdateEnabled
- whether to allow column values to be set
DBException
- invalidColumnNumber
- if column number is invalid (less than 1)
DBException
- columnAlreadyDefined
- if a column is already defined at the specified position
DBException
- duplicateColumn
- if a column with this label has already been defined
java.sql.SQLException
setColumnName(int, java.lang.String)
,
setColumnLabel(int, java.lang.String)
,
setColumnClass(int, java.lang.Class)
,
setUpdateEnabled(int, boolean)
public void setColumnClass(int column, java.lang.Class aClass) throws DBException, java.sql.SQLException
column
- the column number
DBException
- invalidColumnNumber
- if column number is invalid (less than 1)
java.sql.SQLException
- if a database access error occursgetColumnClass(int)
public void setColumnLabel(int column, java.lang.String label) throws DBException, java.sql.SQLException
If you allow the name and label to be filled in when the statement executes, and the unqualified column name is not unique, the label will be suffixed with a number to make it unique.
In methods of DBSelect and DBProcedureCall that access columns by "name", it is actually the column label that is being matched.
column
- the column numberlabel
- the column label String
DBException
- invalidColumnNumber
- if column number is invalid (less than 1)
DBException
- duplicateColumn
- if a column with the specified label has already been defined
java.sql.SQLException
- if a database access error occursgetColumnLabel(int)
,
setColumnName(int, java.lang.String)
public void setColumnName(int column, java.lang.String aName) throws DBException, java.sql.SQLException
setTableName
, setSchemaName
,
and setCatalogName
.
If you do not specify a name, it will be filled in when the statement executes.
In methods of DBSelect and DBProcedureCall that access columns by "name", it is actually the column label that is being matched.
If you set the column name, and its label is null, the label will automatically be set to the name value. Note that the label must be unique without qualification by the table name, schema name, etc.
column
- the column numberaName
- the column name String
DBException
- invalidColumnNumber
- if column number is invalid (less than 1)
DBException
- duplicateColumn
- if a column with the specified label has already been defined
java.sql.SQLException
- if a database access error occursgetColumnName(int)
,
setColumnLabel(int, java.lang.String)
public void setKey(int column, boolean isKey) throws DBException, java.sql.SQLException
If you identify one or more columns as belonging to a "key", when the associated DBSelect or DBProcedureCall bean attempts to locate a row in order to lock it, update it, delete it, etc., it will use the key columns to do so. Otherwise, it will use all of the columns to locate the row, which is a less efficient process.
You may identify one or more columns as the "key" even if no key is actually declared in the database. You should do so only if you are certain that these columns can uniquely identify a row.
column
- the column numberisKey
- true if the column belongs to a "key"; false otherwise
DBException
- invalidColumnNumber
- if column number is invalid (less than 1)
java.sql.SQLException
- if a database access error occursisKey(int)
public void setScale(int column, int scale) throws DBException, java.sql.SQLException
column
- the column numberscale
- the number of digits to the right of the decimal point
DBException
- invalidColumnNumber
- if column number is invalid (less than 1)
java.sql.SQLException
- if a database access error occursgetScale(int)
public void setSchemaName(int column, java.lang.String name) throws DBException, java.sql.SQLException
column
- the column numbername
- the schema name.
DBException
- invalidColumnNumber
- if column number is invalid (less than 1)
java.sql.SQLException
- if a database access error occursgetSchemaName(int)
public void setTableForUpdate(java.lang.String name) throws DBException
The name may be the unqualified table name, or may be qualified. It will be substituted exactly as specified into Update, Insert, or Delete statements.
name
- name of the table to update
DBException
getTableForUpdate()
public void setTableName(int column, java.lang.String name) throws DBException, java.sql.SQLException
column
- the column numbername
- the table name.
DBException
- invalidColumnNumber
- if column number is invalid (less than 1)
java.sql.SQLException
- if a database access error occursgetTableName(int)
public void setUpdateEnabled(int column, boolean updateEnabled) throws DBException, java.sql.SQLException
If you set this value to false, you will not be allowed to set a value in this column via the associated DBSelect or DBProcedureCall bean even if the associated bean itself is not readOnly.
If you set this value to true, you will be allowed to set a value in this column via the associated DBSelect or DBProcedureCall as long as the associated bean is not readOnly.
By default, updateEnabled is true.
column
- the column numberupdateEnabled
- true to allow values to be set; false to
prevent values from being set
DBException
- invalidColumnNumber
- if column number is invalid (less than 1)
java.sql.SQLException
- if a database access error occursisUpdateEnabled(int)
,
isWritable(int)
,
DBSelect.isReadOnly()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |