Class Hierarchy All Classes All Fields and Methods

 

Class com.ibm.db.beans.DBSelectMetaData

java.lang.Object
        com.ibm.db.beans.DBSelectMetaData

public class DBSelectMetaData
implements Serializable
extends Object

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 Index
Method Description
void clear() Clears the descriptions of all columns in this result set.
String getCatalogName(int) Gets the catalog name of the table of the specified column.
Class getColumnClass(int) 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.
String getColumnLabel(int) Gets the label for this column, which may be different from its name.
String getColumnName(int) Gets a column's name.
int getColumnNumber(String) Gets the number of a column based on its label.
int getColumnType(int) Gets a column's SQL type.
ResultSetMetaData getResultSetMetaData() Gets a reference to the java.sql.ResultSetMetaData object obtained when the associated statement was executed.
int getScale(int) Gets the number of digits to the right of the decimal point.
String getSchemaName(int) Gets the table schema of this column.
String getTableForUpdate() Gets the name of the table to be the target for Update, Insert, and Delete statements generated by the DBSelect bean.
String getTableName(int) Gets the table name of this column.
boolean isKey(int) Indicates whether this column belongs to a set of columns that can uniquely identify a row in the result set.
boolean isUpdateEnabled(int) 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) Indicates whether it is possible to use the associated DBSelect or DBProcedureCall to change database values in this column.
void setCatalogName(int, String) Sets the catalog name of the table of the specified column.
void setColumn(int, String, String, Class, boolean) Adds the definition of a new column to this bean.
void setColumnClass(int, Class) Sets the Java class to be used when getting or setting values for this column.
void setColumnLabel(int, String) Sets the label for this column, which may be different from its name.
void setColumnName(int, String) Sets the name for this column.
void setKey(int, boolean) 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, int) Sets the number of digits to the right of the decimal point for this column.
void setSchemaName(int, String) Sets the schema name of the table of this column The index of the first column is 1.
void setTableForUpdate(String) Specifies the name of the table to be the target for Update, Insert, and Delete statements generated by the DBSelect bean.
void setTableName(int, String) Sets the name of the table of this column.
void setUpdateEnabled(int, boolean) 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

 

clear

public void clear() 

Clears the descriptions of all columns in this result set.

 

getCatalogName

public String getCatalogName(int column) throws DBException, SQLException

Gets the catalog name of the table of the specified column. The index of the first column is 1.

 

getColumnClass

public Class getColumnClass(int column) throws DBException, SQLException

Gets the Java class to be used when getting or setting values for this column. The index of the first column is 1.

 

getColumnCount

public int getColumnCount() throws SQLException

Gets the number of columns in this RowSet. If information has been specified sparsely (for only some columns) in this bean, the value returned is the number of the last column for which information has been specified.

 

getColumnLabel

public String getColumnLabel(int column) throws DBException, SQLException

Gets the label for this column, which may be different from its name. The index of the first column is 1. The label is guaranteed to be unique (without qualification by the table name, etc.) within the columns defined in this bean. If you do not specify a label, it defaults to the column name.

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.

 

getColumnName

public String getColumnName(int column) throws DBException, SQLException

Gets a column's name. The index of the first column is 1. The name returned is the unqualified name. The name of its table, schema, and catalog (if known) are returned in 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.)

 

getColumnNumber

public int getColumnNumber(String name) throws DBException

Gets the number of a column based on its label. The number of the first column is 1.

 

getColumnType

public int getColumnType(int column) throws DBException, SQLException

Gets a column's SQL type. The number of the first column is 1.

 

getResultSetMetaData

public ResultSetMetaData getResultSetMetaData() 

Gets a reference to the java.sql.ResultSetMetaData object obtained when the associated statement was executed. Until the statement has been executed, this returns a null value.

 

getScale

public int getScale(int column) throws DBException, SQLException

Gets the number of digits to the right of the decimal point. The index of the first column is 1. This value is only used for columns whose SQL type is decimal.

 

getSchemaName

public String getSchemaName(int column) throws DBException, SQLException

Gets the table schema of this column. The index of the first column is 1.

 

getTableForUpdate

public String getTableForUpdate() 

Gets the name of the table to be the target for Update, Insert, and Delete statements generated by the DBSelect bean.

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.

 

getTableName

public String getTableName(int column) throws DBException, SQLException

Gets the table name of this column. The index of the first column is 1.

 

isKey

public boolean isKey(int column) throws DBException

Indicates whether this column belongs to a set of columns that can uniquely identify a row in the result set. The index of the first column is 1.

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.

 

isUpdateEnabled

public boolean isUpdateEnabled(int column) throws DBException, SQLException

Indicates whether to allow values in this column to be set and then updated in the database using an associated DBSelect or DBProcedureCall. The index of the first column is 1.

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.

 

isWritable

public boolean isWritable(int column) throws DBException, SQLException

Indicates whether it is possible to use the associated DBSelect or DBProcedureCall to change database values in this column. The index of the first column is 1.

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.

 

setCatalogName

public void setCatalogName(int column,
                           String name) throws DBException, SQLException

Sets the catalog name of the table of the specified column. The index of the first column is 1.

 

setColumn

public synchronized void setColumn(int column,
                                   String name,
                                   String label,
                                   Class aClass,
                                   boolean updateEnabled) throws DBException, SQLException

Adds the definition of a new column to this bean. This is a convenience method that allows you specify multiple characteristics of the column at once rather than separately calling several other methods to set them.

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.

 

setColumnClass

public synchronized void setColumnClass(int column,
                                        Class aClass) throws DBException, SQLException

Sets the Java class to be used when getting or setting values for this column. The index of the first column is 1.

 

setColumnLabel

public void setColumnLabel(int column,
                           String label) throws DBException, SQLException

Sets the label for this column, which may be different from its name. The index of the first column is 1. Uniqueness of the label (without qualification by the table name, etc.) is enforced within the columns defined in this bean. If you do not specify a label, it defaults to the column name.

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.

 

setColumnName

public void setColumnName(int column,
                          String aName) throws DBException, SQLException

Sets the name for this column. The index of the first column is 1. The name specified is the unqualified name. The name of its table, schema, and catalog (if known) are set via 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.

 

setKey

public void setKey(int column,
                   boolean isKey) throws DBException, SQLException

Sets specification of whether this column belongs to a set of columns that can uniquely identify a row in the result set. The index of the first column is 1.

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.

 

setScale

public void setScale(int column,
                     int scale) throws DBException, SQLException

Sets the number of digits to the right of the decimal point for this column. The index of the first column is 1. This value is only used for columns whose SQL type is decimal.

 

setSchemaName

public void setSchemaName(int column,
                          String name) throws DBException, SQLException

Sets the schema name of the table of this column The index of the first column is 1.

 

setTableForUpdate

public void setTableForUpdate(String name) throws DBException

Specifies the name of the table to be the target for Update, Insert, and Delete statements generated by the DBSelect bean. If you do not provide a table name, the query will be parsed to determine what name to use.

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.

 

setTableName

public void setTableName(int column,
                         String name) throws DBException, SQLException

Sets the name of the table of this column. The index of the first column is 1.

 

setUpdateEnabled

public void setUpdateEnabled(int column,
                             boolean updateEnabled) throws DBException, SQLException

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. The index of the first column is 1.

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.

Class Hierarchy All Classes All Fields and Methods