Package org.springframework.jdbc.core
Class SqlParameter
- java.lang.Object
- org.springframework.jdbc.core.SqlParameter
- Direct Known Subclasses:
ResultSetSupportingSqlParameter
,SqlParameterValue
,SqlReturnUpdateCount
public class SqlParameter extends Object
Object to represent a SQL parameter definition.Parameters may be anonymous, in which case "name" is
null
. However, all parameters must define a SQL type according toTypes
.- Author:
- Rod Johnson, Thomas Risberg, Juergen Hoeller
- See Also:
Types
Constructor Summary
Constructors Constructor Description SqlParameter(int sqlType)
Create a new anonymous SqlParameter, supplying the SQL type.SqlParameter(int sqlType, int scale)
Create a new anonymous SqlParameter, supplying the SQL type.SqlParameter(int sqlType, String typeName)
Create a new anonymous SqlParameter, supplying the SQL type.SqlParameter(String name, int sqlType)
Create a new SqlParameter, supplying name and SQL type.SqlParameter(String name, int sqlType, int scale)
Create a new SqlParameter, supplying name and SQL type.SqlParameter(String name, int sqlType, String typeName)
Create a new SqlParameter, supplying name and SQL type.SqlParameter(SqlParameter otherParam)
Copy constructor.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getName()
Return the name of the parameter, ornull
if anonymous.Integer
getScale()
Return the scale of the parameter, if any.int
getSqlType()
Return the SQL type of the parameter.String
getTypeName()
Return the type name of the parameter, if any.boolean
isInputValueProvided()
Return whether this parameter holds input values that should be set before execution even if they arenull
.boolean
isResultsParameter()
Return whether this parameter is an implicit return parameter used during the results processing ofCallableStatement.getMoreResults/getUpdateCount
.static List<SqlParameter>
sqlTypesToAnonymousParameterList(int... types)
Convert a list of JDBC types, as defined injava.sql.Types
, to a List of SqlParameter objects as used in this package.
Constructor Detail
SqlParameter
public SqlParameter(int sqlType)
Create a new anonymous SqlParameter, supplying the SQL type.- Parameters:
sqlType
- SQL type of the parameter according tojava.sql.Types
SqlParameter
public SqlParameter(int sqlType, String typeName)
Create a new anonymous SqlParameter, supplying the SQL type.- Parameters:
sqlType
- SQL type of the parameter according tojava.sql.Types
typeName
- the type name of the parameter (optional)
SqlParameter
public SqlParameter(int sqlType, int scale)
Create a new anonymous SqlParameter, supplying the SQL type.- Parameters:
sqlType
- SQL type of the parameter according tojava.sql.Types
scale
- the number of digits after the decimal point (for DECIMAL and NUMERIC types)
SqlParameter
public SqlParameter(String name, int sqlType)
Create a new SqlParameter, supplying name and SQL type.- Parameters:
name
- name of the parameter, as used in input and output mapssqlType
- SQL type of the parameter according tojava.sql.Types
SqlParameter
public SqlParameter(String name, int sqlType, String typeName)
Create a new SqlParameter, supplying name and SQL type.- Parameters:
name
- name of the parameter, as used in input and output mapssqlType
- SQL type of the parameter according tojava.sql.Types
typeName
- the type name of the parameter (optional)
SqlParameter
public SqlParameter(String name, int sqlType, int scale)
Create a new SqlParameter, supplying name and SQL type.- Parameters:
name
- name of the parameter, as used in input and output mapssqlType
- SQL type of the parameter according tojava.sql.Types
scale
- the number of digits after the decimal point (for DECIMAL and NUMERIC types)
SqlParameter
public SqlParameter(SqlParameter otherParam)
Copy constructor.- Parameters:
otherParam
- the SqlParameter object to copy from
Method Detail
getSqlType
public int getSqlType()
Return the SQL type of the parameter.
getTypeName
public String getTypeName()
Return the type name of the parameter, if any.
isInputValueProvided
public boolean isInputValueProvided()
Return whether this parameter holds input values that should be set before execution even if they arenull
.This implementation always returns
true
.
isResultsParameter
public boolean isResultsParameter()
Return whether this parameter is an implicit return parameter used during the results processing ofCallableStatement.getMoreResults/getUpdateCount
.This implementation always returns
false
.
sqlTypesToAnonymousParameterList
public static List<SqlParameter> sqlTypesToAnonymousParameterList(int... types)
Convert a list of JDBC types, as defined injava.sql.Types
, to a List of SqlParameter objects as used in this package.