org.springframework.jdbc.core
Class SqlParameter

java.lang.Object
  extended by org.springframework.jdbc.core.SqlParameter
Direct Known Subclasses:
ResultSetSupportingSqlParameter, SqlParameterValue, SqlReturnUpdateCount

public class SqlParameter
extends java.lang.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 to Types.

Author:
Rod Johnson, Thomas Risberg, Juergen Hoeller
See Also:
Types

Field Summary
private  java.lang.String name
          The name of the parameter, if any
private  java.lang.Integer scale
          The scale to apply in case of a NUMERIC or DECIMAL type, if any
private  int sqlType
          SQL type constant from java.sql.Types
private  java.lang.String typeName
          Used for types that are user-named like: STRUCT, DISTINCT, JAVA_OBJECT, named array types
 
Constructor Summary
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, java.lang.String typeName)
          Create a new anonymous SqlParameter, supplying the SQL type.
SqlParameter(SqlParameter otherParam)
          Copy constructor.
SqlParameter(java.lang.String name, int sqlType)
          Create a new SqlParameter, supplying name and SQL type.
SqlParameter(java.lang.String name, int sqlType, int scale)
          Create a new SqlParameter, supplying name and SQL type.
SqlParameter(java.lang.String name, int sqlType, java.lang.String typeName)
          Create a new SqlParameter, supplying name and SQL type.
 
Method Summary
 java.lang.String getName()
          Return the name of the parameter.
 java.lang.Integer getScale()
          Return the scale of the parameter, if any.
 int getSqlType()
          Return the SQL type of the parameter.
 java.lang.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 are null.
 boolean isResultsParameter()
          Return whether this parameter is an implicit return parameter used during the results preocessing of the CallableStatement.getMoreResults/getUpdateCount.
static java.util.List<SqlParameter> sqlTypesToAnonymousParameterList(int[] types)
          Convert a list of JDBC types, as defined in java.sql.Types, to a List of SqlParameter objects as used in this package.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private java.lang.String name
The name of the parameter, if any


sqlType

private final int sqlType
SQL type constant from java.sql.Types


typeName

private java.lang.String typeName
Used for types that are user-named like: STRUCT, DISTINCT, JAVA_OBJECT, named array types


scale

private java.lang.Integer scale
The scale to apply in case of a NUMERIC or DECIMAL type, if any

Constructor Detail

SqlParameter

public SqlParameter(int sqlType)
Create a new anonymous SqlParameter, supplying the SQL type.

Parameters:
sqlType - SQL type of the parameter according to java.sql.Types

SqlParameter

public SqlParameter(int sqlType,
                    java.lang.String typeName)
Create a new anonymous SqlParameter, supplying the SQL type.

Parameters:
sqlType - SQL type of the parameter according to java.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 to java.sql.Types
scale - the number of digits after the decimal point (for DECIMAL and NUMERIC types)

SqlParameter

public SqlParameter(java.lang.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 maps
sqlType - SQL type of the parameter according to java.sql.Types

SqlParameter

public SqlParameter(java.lang.String name,
                    int sqlType,
                    java.lang.String typeName)
Create a new SqlParameter, supplying name and SQL type.

Parameters:
name - name of the parameter, as used in input and output maps
sqlType - SQL type of the parameter according to java.sql.Types
typeName - the type name of the parameter (optional)

SqlParameter

public SqlParameter(java.lang.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 maps
sqlType - SQL type of the parameter according to java.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

getName

public java.lang.String getName()
Return the name of the parameter.


getSqlType

public int getSqlType()
Return the SQL type of the parameter.


getTypeName

public java.lang.String getTypeName()
Return the type name of the parameter, if any.


getScale

public java.lang.Integer getScale()
Return the scale 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 are null.

This implementation always returns true.


isResultsParameter

public boolean isResultsParameter()
Return whether this parameter is an implicit return parameter used during the results preocessing of the CallableStatement.getMoreResults/getUpdateCount.

This implementation always returns false.


sqlTypesToAnonymousParameterList

public static java.util.List<SqlParameter> sqlTypesToAnonymousParameterList(int[] types)
Convert a list of JDBC types, as defined in java.sql.Types, to a List of SqlParameter objects as used in this package.