Package java.sql

Interface ParameterMetaData

All Superinterfaces:
Wrapper

public interface ParameterMetaData
extends Wrapper
An interface used to get information about the types and properties of parameters in a PreparedStatement.
  • Field Summary

    Fields
    Modifier and Type Field Description
    static int parameterModeIn
    Indicates that the parameter mode is IN.
    static int parameterModeInOut
    Indicates that the parameter mode is INOUT.
    static int parameterModeOut
    Indicates that the parameter mode is OUT.
    static int parameterModeUnknown
    Indicates that the parameter mode is not known.
    static int parameterNoNulls
    Indicates that a parameter is not permitted to be NULL.
    static int parameterNullable
    Indicates that a parameter is permitted to be NULL.
    static int parameterNullableUnknown
    Indicates that whether a parameter is allowed to be null or not is not known.
  • Method Summary

    Modifier and Type Method Description
    String getParameterClassName​(int paramIndex)
    Gets the fully-qualified name of the Java class which should be passed as a parameter to the method PreparedStatement.setObject.
    int getParameterCount()
    Gets the number of parameters in the PreparedStatement for which this ParameterMetaData contains information.
    int getParameterMode​(int paramIndex)
    Gets the mode of the specified parameter.
    int getParameterType​(int paramIndex)
    Gets the SQL type of a specified parameter.
    String getParameterTypeName​(int paramIndex)
    Gets the database-specific type name of a specified parameter.
    int getPrecision​(int paramIndex)
    Gets the number of decimal digits for a specified parameter.
    int getScale​(int paramIndex)
    Gets the number of digits after the decimal point for a specified parameter.
    int isNullable​(int paramIndex)
    Gets whether null values are allowed for the specified parameter.
    boolean isSigned​(int paramIndex)
    Gets whether values for the specified parameter can be signed numbers.

    Methods inherited from interface java.sql.Wrapper

    isWrapperFor, unwrap
  • Field Details

    • parameterModeIn

      static final int parameterModeIn
      Indicates that the parameter mode is IN.
      See Also:
      Constant Field Values
    • parameterModeInOut

      static final int parameterModeInOut
      Indicates that the parameter mode is INOUT.
      See Also:
      Constant Field Values
    • parameterModeOut

      static final int parameterModeOut
      Indicates that the parameter mode is OUT.
      See Also:
      Constant Field Values
    • parameterModeUnknown

      static final int parameterModeUnknown
      Indicates that the parameter mode is not known.
      See Also:
      Constant Field Values
    • parameterNoNulls

      static final int parameterNoNulls
      Indicates that a parameter is not permitted to be NULL.
      See Also:
      Constant Field Values
    • parameterNullable

      static final int parameterNullable
      Indicates that a parameter is permitted to be NULL.
      See Also:
      Constant Field Values
    • parameterNullableUnknown

      static final int parameterNullableUnknown
      Indicates that whether a parameter is allowed to be null or not is not known.
      See Also:
      Constant Field Values
  • Method Details

    • getParameterClassName

      String getParameterClassName​(int paramIndex) throws SQLException
      Gets the fully-qualified name of the Java class which should be passed as a parameter to the method PreparedStatement.setObject.
      Parameters:
      paramIndex - the index number of the parameter, where the first parameter has index 1.
      Returns:
      the fully qualified Java class name of the parameter with the specified index. This class name is used for custom mapping between SQL types and Java objects.
      Throws:
      SQLException - if a database error happens.
    • getParameterCount

      int getParameterCount() throws SQLException
      Gets the number of parameters in the PreparedStatement for which this ParameterMetaData contains information.
      Returns:
      the number of parameters.
      Throws:
      SQLException - if a database error happens.
    • getParameterMode

      int getParameterMode​(int paramIndex) throws SQLException
      Gets the mode of the specified parameter. Can be one of:
      • ParameterMetaData.parameterModeIn
      • ParameterMetaData.parameterModeOut
      • ParameterMetaData.parameterModeInOut
      • ParameterMetaData.parameterModeUnknown
      Parameters:
      paramIndex - the index number of the parameter, where the first parameter has index 1.
      Returns:
      the parameter's mode.
      Throws:
      SQLException - if a database error happens.
    • getParameterType

      int getParameterType​(int paramIndex) throws SQLException
      Gets the SQL type of a specified parameter.
      Parameters:
      paramIndex - the index number of the parameter, where the first parameter has index 1.
      Returns:
      the SQL type of the parameter as defined in java.sql.Types.
      Throws:
      SQLException - if a database error happens.
    • getParameterTypeName

      String getParameterTypeName​(int paramIndex) throws SQLException
      Gets the database-specific type name of a specified parameter.
      Parameters:
      paramIndex - the index number of the parameter, where the first parameter has index 1.
      Returns:
      the type name for the parameter as used by the database. A fully-qualified name is returned if the parameter is a User Defined Type (UDT).
      Throws:
      SQLException - if a database error happens.
    • getPrecision

      int getPrecision​(int paramIndex) throws SQLException
      Gets the number of decimal digits for a specified parameter.
      Parameters:
      paramIndex - the index number of the parameter, where the first parameter has index 1.
      Returns:
      the number of decimal digits ("the precision") for the parameter. 0 if the parameter is not a numeric type.
      Throws:
      SQLException - if a database error happens.
    • getScale

      int getScale​(int paramIndex) throws SQLException
      Gets the number of digits after the decimal point for a specified parameter.
      Parameters:
      paramIndex - the index number of the parameter, where the first parameter has index 1.
      Returns:
      the number of digits after the decimal point ("the scale") for the parameter. 0 if the parameter is not a numeric type.
      Throws:
      SQLException - if a database error happens.
    • isNullable

      int isNullable​(int paramIndex) throws SQLException
      Gets whether null values are allowed for the specified parameter. The returned value is one of:
      • ParameterMetaData.parameterNoNulls
      • ParameterMetaData.parameterNullable
      • ParameterMetaData.parameterNullableUnknown
      Parameters:
      paramIndex - the index number of the parameter, where the first parameter has index 1.
      Returns:
      the int code indicating the nullability of the parameter.
      Throws:
      SQLException - if a database error is encountered.
    • isSigned

      boolean isSigned​(int paramIndex) throws SQLException
      Gets whether values for the specified parameter can be signed numbers.
      Parameters:
      paramIndex - the index number of the parameter, where the first parameter has index 1.
      Returns:
      true if values can be signed numbers for this parameter, false otherwise.
      Throws:
      SQLException - if a database error happens.