Top Description Fields Constructors Methods
org.apache.derby.impl.sql

pack-priv final Class GenericParameterValueSet

extends Object
implements ParameterValueSet
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.sql.ParameterValueSet
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.loader.ClassInspector, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.sql.ParameterValueSet, org.apache.derby.iapi.types.DataTypeDescriptor, .DataValueDescriptor, .UserDataValue, org.apache.derby.impl.jdbc.Util, java.io.InputStream, java.sql.ParameterMetaData, .Types

Implementation of ParameterValueSet
See Also
ParameterValueSet

Field Summary

Modifier and TypeField and Description
pack-priv final ClassInspector
private final boolean
private final GenericParameter[]

Constructor Summary

AccessConstructor and Description
pack-priv
GenericParameterValueSet(ClassInspector ci, int
The number of parameters in the new ParameterValueSet
numParms
,
boolean
if we have a ? = call syntax. Note that this is NOT the same thing as an output parameter -- return output parameters are special cases of output parameters.
hasReturnOutputParam
)

Constructor for a GenericParameterValueSet

private

Method Summary

Modifier and TypeMethod and Description
public boolean
allAreSet()

Implements org.apache.derby.iapi.sql.ParameterValueSet.allAreSet.

Tells whether all the parameters are set and ready for execution.

public boolean

Returns:

true if a declared Java Procedure INOUT or OUT parameter is in the set, false otherwise.
checkNoDeclaredOutputParameters
()

Implements org.apache.derby.iapi.sql.ParameterValueSet.checkNoDeclaredOutputParameters.

Check that there are not output parameters defined by the parameter set.

private void
checkPosition(int
The position number to check
position
)

Check the position number for a parameter and throw an exception if it is out of range.

public void
clearParameters()

Implements org.apache.derby.iapi.sql.ParameterValueSet.clearParameters.

Sets all parameters to an uninitialized state.

public ParameterValueSet
getClone()

Implements org.apache.derby.iapi.sql.ParameterValueSet.getClone.

Clone the ParameterValueSet and its contents.

pack-priv GenericParameter
getGenericParameter(int position)

public DataValueDescriptor

Returns:

The parameter at the given position.
getParameter
(int
The parameters's position in the set
position
)

Implements org.apache.derby.iapi.sql.ParameterValueSet.getParameter.

Returns the parameter value at the given position.

public int

Returns:

The number of parameters in this set.
getParameterCount
()

Implements org.apache.derby.iapi.sql.ParameterValueSet.getParameterCount.

Returns the number of parameters in this set.

public DataValueDescriptor
getParameterForGet(int
Zero based index of the parameter.
position
)

Implements org.apache.derby.iapi.sql.ParameterValueSet.getParameterForGet.

Get the DataValueDescriptor for an INOUT or OUT parameter.

public DataValueDescriptor
getParameterForSet(int
The parameters's position in the set
position
)

Implements org.apache.derby.iapi.sql.ParameterValueSet.getParameterForSet.

Returns the parameter at the given position in order to set it.

public short
getParameterMode(int
the first parameter is 1, the second is 2, ...
parameterIndex
)

Implements org.apache.derby.iapi.sql.ParameterValueSet.getParameterMode.

Return the mode of the parameter according to JDBC 3.0 ParameterMetaData

public int

Returns:

the parameter number, or 0 if not found
getParameterNumber
(GenericParameter theParam)

Return the parameter number (in jdbc lingo, i.e. 1 based) for the given parameter.

public int

Returns:

precision
getPrecision
(int
the first parameter is 1, the second is 2, ...
parameterIndex
)

Implements org.apache.derby.iapi.sql.ParameterValueSet.getPrecision.

Return the precision of the given parameter index in this pvs.

public DataValueDescriptor
getReturnValueForSet()

Implements org.apache.derby.iapi.sql.ParameterValueSet.getReturnValueForSet.

Get the value of the return parameter in order to set it.

public int

Returns:

scale
getScale
(int
the first parameter is 1, the second is 2, ...
parameterIndex
)

Implements org.apache.derby.iapi.sql.ParameterValueSet.getScale.

Return the scale of the given parameter index in this pvs.

public boolean

Returns:

true if it has a return parameter
hasReturnOutputParameter
()

Implements org.apache.derby.iapi.sql.ParameterValueSet.hasReturnOutputParameter.

Is there a return output parameter in this pvs.

public void
initialize(DataTypeDescriptor[]
expected to match the number of parameters.
types
)

Implements org.apache.derby.iapi.sql.ParameterValueSet.initialize.

Initialize the set by allocating a holder DataValueDescriptor object for each parameter.

public void
registerOutParameter(int
The ordinal parameterIndex of a parameter to set to the given value.
parameterIndex
,
int
A type from java.sql.Types
jdbcType
,
int
the scale to use. -1 means ignore scale
scale
)

Implements org.apache.derby.iapi.sql.ParameterValueSet.registerOutParameter.

Mark the parameter as an output parameter.

public void
setParameterAsObject(int
The position of the parameter
position
,
Object
It's value
value
)

Implements org.apache.derby.iapi.sql.ParameterValueSet.setParameterAsObject.

Set the value of this user defined parameter to the passed in Object.

public void
setParameterMode(int
The position of the parameter in the set
position
,
int
The IN/OUT mode to set
mode
)

Implements org.apache.derby.iapi.sql.ParameterValueSet.setParameterMode.

Set the mode of the parameter, called when setting up static method calls and stored procedures.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
transferDataValues(ParameterValueSet
ParameterValueSet which will recieve the values
pvstarget
)

Implements org.apache.derby.iapi.sql.ParameterValueSet.transferDataValues.

Set the parameter values of the pvstarget to equal those set in this PVS.

public void
validate()

Implements org.apache.derby.iapi.sql.ParameterValueSet.validate.

Validate the parameters.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

ciback to summary
pack-priv final ClassInspector ci
hasReturnOutputParamback to summary
private final boolean hasReturnOutputParam
parmsback to summary
private final GenericParameter[] parms

Constructor Detail

GenericParameterValueSetback to summary
pack-priv GenericParameterValueSet(ClassInspector ci, int numParms, boolean hasReturnOutputParam)

Constructor for a GenericParameterValueSet

Parameters
numParms:int

The number of parameters in the new ParameterValueSet

hasReturnOutputParam:boolean

if we have a ? = call syntax. Note that this is NOT the same thing as an output parameter -- return output parameters are special cases of output parameters.

GenericParameterValueSetback to summary
private GenericParameterValueSet(int numParms, GenericParameterValueSet pvs)

Method Detail

allAreSetback to summary
public boolean allAreSet()

Implements org.apache.derby.iapi.sql.ParameterValueSet.allAreSet.

Doc from org.apache.derby.iapi.sql.ParameterValueSet.allAreSet.

Tells whether all the parameters are set and ready for execution. OUT are not required to be set.

Returns:boolean

true if all parameters are set, false if at least one parameter is not set.

See Also
ParameterValueSet#allAreSet
checkNoDeclaredOutputParametersback to summary
public boolean checkNoDeclaredOutputParameters()

Implements org.apache.derby.iapi.sql.ParameterValueSet.checkNoDeclaredOutputParameters.

Check that there are not output parameters defined by the parameter set. If there are unknown parameter types they are forced to input types. i.e. Derby static method calls with parameters that are array.

Returns:boolean

true if a declared Java Procedure INOUT or OUT parameter is in the set, false otherwise.

checkPositionback to summary
private void checkPosition(int position) throws StandardException

Check the position number for a parameter and throw an exception if it is out of range.

Parameters
position:int

The position number to check

Exceptions
StandardException:
Thrown if position number is out of range.
clearParametersback to summary
public void clearParameters()

Implements org.apache.derby.iapi.sql.ParameterValueSet.clearParameters.

Doc from org.apache.derby.iapi.sql.ParameterValueSet.clearParameters.

Sets all parameters to an uninitialized state. An exception will be thrown if the caller tries to execute a PreparedStatement when one or more parameters is uninitialized (i.e. has not had setParameterValue() called on it.

See Also
ParameterValueSet#clearParameters
getCloneback to summary
public ParameterValueSet getClone()

Implements org.apache.derby.iapi.sql.ParameterValueSet.getClone.

Doc from org.apache.derby.iapi.sql.ParameterValueSet.getClone.

Clone the ParameterValueSet and its contents.

Returns:ParameterValueSet

ParameterValueSet A clone of the ParameterValueSet and its contents.

getGenericParameterback to summary
pack-priv GenericParameter getGenericParameter(int position)
getParameterback to summary
public DataValueDescriptor getParameter(int position) throws StandardException

Implements org.apache.derby.iapi.sql.ParameterValueSet.getParameter.

Returns the parameter value at the given position.

Parameters
position:int

Doc from org.apache.derby.iapi.sql.ParameterValueSet.getParameter.

The parameters's position in the set

Returns:DataValueDescriptor

The parameter at the given position.

Exceptions
StandardException:
Thrown on error
getParameterCountback to summary
public int getParameterCount()

Implements org.apache.derby.iapi.sql.ParameterValueSet.getParameterCount.

Returns the number of parameters in this set.

Returns:int

The number of parameters in this set.

getParameterForGetback to summary
public DataValueDescriptor getParameterForGet(int position) throws StandardException

Implements org.apache.derby.iapi.sql.ParameterValueSet.getParameterForGet.

Doc from org.apache.derby.iapi.sql.ParameterValueSet.getParameterForGet.

Get the DataValueDescriptor for an INOUT or OUT parameter.

Parameters
position:int

Zero based index of the parameter.

Returns:DataValueDescriptor

Parameter's value holder.

Exceptions
StandardException:
Position out of range or the parameter is not INOUT or OUT.
getParameterForSetback to summary
public DataValueDescriptor getParameterForSet(int position) throws StandardException

Implements org.apache.derby.iapi.sql.ParameterValueSet.getParameterForSet.

Doc from org.apache.derby.iapi.sql.ParameterValueSet.getParameterForSet.

Returns the parameter at the given position in order to set it. Setting via an unknown object type must use setParameterAsObject() to ensure correct typing.

Parameters
position:int

The parameters's position in the set

Returns:DataValueDescriptor

The parameter at the given position.

Exceptions
StandardException:
Thrown on error
getParameterModeback to summary
public short getParameterMode(int parameterIndex)

Implements org.apache.derby.iapi.sql.ParameterValueSet.getParameterMode.

Return the mode of the parameter according to JDBC 3.0 ParameterMetaData

Parameters
parameterIndex:int

the first parameter is 1, the second is 2, ...

Returns:short

Doc from org.apache.derby.iapi.sql.ParameterValueSet.getParameterMode.

the IN/OUT mode of the parameter

getParameterNumberback to summary
public int getParameterNumber(GenericParameter theParam)

Return the parameter number (in jdbc lingo, i.e. 1 based) for the given parameter. Linear search.

Returns:int

the parameter number, or 0 if not found

getPrecisionback to summary
public int getPrecision(int parameterIndex)

Implements org.apache.derby.iapi.sql.ParameterValueSet.getPrecision.

Return the precision of the given parameter index in this pvs.

Parameters
parameterIndex:int

the first parameter is 1, the second is 2, ...

Returns:int

precision

getReturnValueForSetback to summary
public DataValueDescriptor getReturnValueForSet() throws StandardException

Implements org.apache.derby.iapi.sql.ParameterValueSet.getReturnValueForSet.

Get the value of the return parameter in order to set it.

Returns:DataValueDescriptor

Doc from org.apache.derby.iapi.sql.ParameterValueSet.getReturnValueForSet.

the return parameter

Exceptions
StandardException:
if a database-access error occurs.
getScaleback to summary
public int getScale(int parameterIndex)

Implements org.apache.derby.iapi.sql.ParameterValueSet.getScale.

Return the scale of the given parameter index in this pvs.

Parameters
parameterIndex:int

the first parameter is 1, the second is 2, ...

Returns:int

scale

hasReturnOutputParameterback to summary
public boolean hasReturnOutputParameter()

Implements org.apache.derby.iapi.sql.ParameterValueSet.hasReturnOutputParameter.

Is there a return output parameter in this pvs. A return parameter is from a CALL statement of the following syntax: ? = CALL myMethod()

Returns:boolean

true if it has a return parameter

initializeback to summary
public void initialize(DataTypeDescriptor[] types) throws StandardException

Implements org.apache.derby.iapi.sql.ParameterValueSet.initialize.

Initialize the set by allocating a holder DataValueDescriptor object for each parameter.

Parameters
types:DataTypeDescriptor[]

Doc from org.apache.derby.iapi.sql.ParameterValueSet.initialize.

expected to match the number of parameters.

Exceptions
StandardException:

Doc from org.apache.derby.iapi.sql.ParameterValueSet.initialize.

on error

registerOutParameterback to summary
public void registerOutParameter(int parameterIndex, int jdbcType, int scale) throws StandardException

Implements org.apache.derby.iapi.sql.ParameterValueSet.registerOutParameter.

Mark the parameter as an output parameter.

Parameters
parameterIndex:int

The ordinal parameterIndex of a parameter to set to the given value.

jdbcType:int

A type from java.sql.Types

scale:int

the scale to use. -1 means ignore scale

Exceptions
StandardException:
on error
setParameterAsObjectback to summary
public void setParameterAsObject(int position, Object value) throws StandardException

Implements org.apache.derby.iapi.sql.ParameterValueSet.setParameterAsObject.

Doc from org.apache.derby.iapi.sql.ParameterValueSet.setParameterAsObject.

Set the value of this user defined parameter to the passed in Object.

Parameters
position:int

The position of the parameter

value:Object

It's value

Exceptions
StandardException:
Thrown on error
setParameterModeback to summary
public void setParameterMode(int position, int mode)

Implements org.apache.derby.iapi.sql.ParameterValueSet.setParameterMode.

Doc from org.apache.derby.iapi.sql.ParameterValueSet.setParameterMode.

Set the mode of the parameter, called when setting up static method calls and stored procedures. Otherwise the parameter type will default to an IN parameter.

Parameters
position:int

The position of the parameter in the set

mode:int

The IN/OUT mode to set

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

transferDataValuesback to summary
public void transferDataValues(ParameterValueSet pvstarget) throws StandardException

Implements org.apache.derby.iapi.sql.ParameterValueSet.transferDataValues.

Doc from org.apache.derby.iapi.sql.ParameterValueSet.transferDataValues.

Set the parameter values of the pvstarget to equal those set in this PVS. Used to transfer saved SPS parameters to the actual prepared statement parameters once associated parameters have been established. Assumes pvstarget is the same length as this.

Parameters
pvstarget:ParameterValueSet

ParameterValueSet which will recieve the values

Exceptions
StandardException:
values not compatible
See Also
ParameterValueSet#transferDataValues
validateback to summary
public void validate() throws StandardException

Implements org.apache.derby.iapi.sql.ParameterValueSet.validate.

Validate the parameters. This is done for situations where we cannot validate everything in the setXXX() calls. In particular, before we do an execute() on a CallableStatement, we need to go through the parameters and make sure that all parameters are set up properly. The motivator for this is that setXXX() can be called either before or after registerOutputParamter(), we cannot be sure we have the types correct until we get to execute().

Exceptions
StandardException:
if the parameters aren't valid