|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.db.beans.DBParameterMetaData
This class allows you to get and set meta-data about the parameters for a DBSelect, DBProcedureCall, or DBModify bean.
You must describe and set any parameters before actually executing a statement.
There is no public constructor for DBParameterMetaData. A DBStatement is
created with a DBParameterMetaData, which you can get with
getParameterMetaData()
.
Convenience methods are provided that allow you specify multiple
characteristics at once for a parameter not previously described.
(setParameter
) Or you can just call individual methods to set
one characteristic of a parameter at a time.
You can use these same more granular methods to change a description
you have previously provided.
You can describe parameters in any order.
The position of the parameter in the result set is determined by the index
used to call the methods that describe it.
Method Summary | |
---|---|
void |
clear()
Clears the descriptions of all parameters for this statement. |
java.lang.Class |
getParameterClass(int position)
Gets the Java class to be used when getting or setting values for the parameter at the specified position. |
int |
getParameterCount()
Gets the number of parameters in the SQL statement. |
int |
getParameterMode(int position)
Gets the mode of the parameter at the specified position. |
java.lang.String |
getParameterName(int position)
Gets the name of the parameter at the specified position. |
int |
getParameterNumber(java.lang.String name)
Gets the number of a parameter based on its name. |
int |
getParameterScale(int position)
Gets the number of digits to the right of the decimal point. |
int |
getParameterType(int position)
Gets the SQL type of the parameter at the specified position. |
com.ibm.db.beans.DBStatement |
getStatement()
Gets the DBStatement object that this object describes. |
void |
setParameter(int position,
java.lang.String name,
int mode,
int sqlType,
java.lang.Class aClass)
Add the definition of a new parameter to this bean. |
void |
setParameterClass(int position,
java.lang.Class aClass)
Sets the Java class to be used when getting or setting values for this parameter. |
void |
setParameterMode(int position,
int mode)
Sets the mode of the parameter at the specified position. |
void |
setParameterName(int position,
java.lang.String aName)
Sets the name of the parameter at the specified position. |
void |
setParameterScale(int position,
int scale)
Sets the number of digits to the right of the decimal point for this parameter. |
void |
setParameterType(int position,
int type)
Sets the SQL type of the parameter at the specified position. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public void clear()
setParameter(int, java.lang.String, int, int, java.lang.Class)
public java.lang.Class getParameterClass(int position) throws DBException
position
- the parameter number
DBException
- parameterNotDefined
- if no parameter has been defined at this positionsetParameterClass(int, java.lang.Class)
public int getParameterCount()
public int getParameterMode(int position) throws DBException
position
- the parameter number
DBException
- parameterNotDefined
- if no parameter has been defined at this positionpublic java.lang.String getParameterName(int position) throws DBException
This bean allows you to specify names for parameters, and methods of DBSelect, DBModify, and DBProcedureCall can access parameters by these names. Each parameter name is guaranteed to be unique within this bean.
Your SQL statement can be written using '?' to represent a parameter, or using a host variable syntax like ':myParamName'.
position
- the parameter number
DBException
- parameterNotDefined
- if no parameter has been defined at this positionsetParameterName(int, java.lang.String)
public int getParameterNumber(java.lang.String name) throws DBException
name
- the name of the parameter
DBException
- parameterNotDefined
- if no parameter has been defined with this namegetParameterName(int)
public int getParameterScale(int position) throws DBException
DBException
- parameterNotDefined
- if no parameter has been defined at this position
SQLException
- if a database access error occurssetParameterScale(int, int)
public int getParameterType(int position) throws DBException
position
- the parameter number
DBException
- parameterNotDefined
- if no parameter has been defined at this positionTypes
,
setParameterType(int, int)
public com.ibm.db.beans.DBStatement getStatement()
The statement property of this object is read-only. This object is created by the DBStatement it describes, and remains associated with that statement for its lifetime.
public void setParameter(int position, java.lang.String name, int mode, int sqlType, java.lang.Class aClass) throws DBException
When you call this method, there must be no parameter currently defined in the position you specify. The index of the first parameter is 1.
The characteristics you can specify are those you would specify via the
methods setParameterName
, setParameterMode
,
setParameterType
,
and setParameterClass
.
position
- the parameter numbername
- the parameter name String, may be nullmode
- the parameter modeaClass
- the java class to be used for parameter values
DBException
- invalidParameterNumber
- if parameter number is invalid (less than 1)
DBException
- parameterAlreadyDefined
- if a parameter is already defined at the specified position
DBException
- duplicateParm
- if a parameter with this name has already been definedsetParameterName(int, java.lang.String)
,
setParameterMode(int, int)
,
setParameterType(int, int)
,
setParameterClass(int, java.lang.Class)
public void setParameterClass(int position, java.lang.Class aClass) throws DBException
position
- the parameter number
DBException
- invalidParameterNumber
- if parameter number is invalid (less than 1)getParameterClass(int)
public void setParameterMode(int position, int mode) throws DBException
Valid modes are those for which constants are defined in DatabaseMetaData, including: procedureColumnIn, procedureColumnInOut, procedureColumnOut, and procedureColumnResult.
position
- the parameter numbermode
- parameter mode
DBException
- invalidParameterNumber
- if parameter number is invalid (less than 1)getParameterMode(int)
,
DatabaseMetaData
public void setParameterName(int position, java.lang.String aName) throws DBException
position
- the parameter numberaName
- parameter name
DBException
- invalidParameterNumber
- if parameter number is invalid (less than 1)
DBException
- duplicateParm
- if a parameter with this name has already been definedgetParameterName(int)
public void setParameterScale(int position, int scale) throws DBException
position
- the parameter numberscale
- parameter scale
DBException
- invalidParameterNumber
- if parameter number is invalid (less than 1)getParameterScale(int)
,
DatabaseMetaData
public void setParameterType(int position, int type) throws DBException
position
- the parameter numbertype
- parameter SQL type
DBException
- invalidParameterNumber
- if parameter number is invalid (less than 1)getParameterType(int)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |