Package org.apache.commons.dbutils
Class OutParameter<T>
- java.lang.Object
-
- org.apache.commons.dbutils.OutParameter<T>
-
- Type Parameters:
T
- the class of the parameter; should be compatible via cast with the class returned by theCallableStatement.getObject(int)
method.
public class OutParameter<T> extends Object
Represents an OUT parameter for a stored procedure. When running a stored procedure withQueryRunner
, pass an instance ofOutParameter
to indicate that the parameter at that index is an OUT parameter. The value of the parameter may be obtained from theOutParameter
instance viagetValue()
.INOUT parameters are also supported by setting the
value
of theOutParameter
instance before invoking the stored procedure.
-
-
Constructor Summary
Constructors Constructor Description OutParameter(int sqlType, Class<T> javaType)
Construct anOutParameter
for the given JDBC SQL type and Java type.OutParameter(int sqlType, Class<T> javaType, T value)
Construct anOutParameter
for the given JDBC SQL type and Java type and with the given value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<T>
getJavaType()
Get the Java class for this OUT parameter.int
getSqlType()
Get the JDBC SQL type for this OUT parameter.T
getValue()
Get the value of the OUT parameter.void
setValue(T value)
Set the value of the OUT parameter.String
toString()
-
-
-
Constructor Detail
-
OutParameter
public OutParameter(int sqlType, Class<T> javaType)
Construct anOutParameter
for the given JDBC SQL type and Java type.- Parameters:
sqlType
- the JDBC SQL type of the parameter as injava.sql.Types
.javaType
- the Java class of the parameter value, cast compatible with the type returned byCallableStatement.getObject(int)
for the JDBC type given bysqlType
.
-
OutParameter
public OutParameter(int sqlType, Class<T> javaType, T value)
Construct anOutParameter
for the given JDBC SQL type and Java type and with the given value. The parameter will be treated as an INOUT parameter if the value is null.- Parameters:
sqlType
- the JDBC SQL type of the parameter as injava.sql.Types
.javaType
- the Java class of the parameter value, cast compatible with the type returned byCallableStatement.getObject(int)
for the JDBC type given bysqlType
.value
- the IN value of the parameter
-
-
Method Detail
-
getJavaType
public Class<T> getJavaType()
Get the Java class for this OUT parameter.- Returns:
- the Java class for this OUT parameter.
-
getSqlType
public int getSqlType()
Get the JDBC SQL type for this OUT parameter.- Returns:
- the JDBC SQL type for this OUT parameter.
-
getValue
public T getValue()
Get the value of the OUT parameter. After the stored procedure has been executed, the value is the value returned via this parameter.- Returns:
- the value of the OUT parameter.
-
setValue
public void setValue(T value)
Set the value of the OUT parameter. If the value is not null when the stored procedure is executed, then the parameter will be treated like an INOUT parameter.- Parameters:
value
- the new value for the parameter.
-
-