Class SqlParameter

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

public class SqlParameter extends Object
Object to represent an SQL parameter definition.

Parameters may be anonymous, in which case "name" is null. However, all parameters must define an SQL type according to Types.

Author:
Rod Johnson, Thomas Risberg, Juergen Hoeller
See Also:
  • 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.
    Copy constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the name of the parameter, or null if anonymous.
    Return the scale of the parameter, if any.
    int
    Return the SQL type of the parameter.
    Return the type name of the parameter, if any.
    boolean
    Return whether this parameter holds input values that should be set before execution even if they are null.
    boolean
    Return whether this parameter is an implicit return parameter used during the results processing of CallableStatement.getMoreResults/getUpdateCount.
    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
  • Constructor Details

    • SqlParameter

      public SqlParameter(int sqlType)
      Create a new anonymous SqlParameter, supplying the SQL type.
      Parameters:
      sqlType - the SQL type of the parameter according to java.sql.Types
    • SqlParameter

      public SqlParameter(int sqlType, @Nullable String typeName)
      Create a new anonymous SqlParameter, supplying the SQL type.
      Parameters:
      sqlType - the 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 - the 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(String name, int sqlType)
      Create a new SqlParameter, supplying name and SQL type.
      Parameters:
      name - the name of the parameter, as used in input and output maps
      sqlType - the SQL type of the parameter according to java.sql.Types
    • SqlParameter

      public SqlParameter(String name, int sqlType, @Nullable String typeName)
      Create a new SqlParameter, supplying name and SQL type.
      Parameters:
      name - the name of the parameter, as used in input and output maps
      sqlType - the SQL type of the parameter according to java.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 - the name of the parameter, as used in input and output maps
      sqlType - the 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 Details

    • getName

      @Nullable public String getName()
      Return the name of the parameter, or null if anonymous.
    • getSqlType

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

      @Nullable public String getTypeName()
      Return the type name of the parameter, if any.
    • getScale

      @Nullable public 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 processing of CallableStatement.getMoreResults/getUpdateCount.

      This implementation always returns false.

    • sqlTypesToAnonymousParameterList

      public static List<SqlParameter> sqlTypesToAnonymousParameterList(@Nullable 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.