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 intparameterModeInIndicates that the parameter mode isIN.static intparameterModeInOutIndicates that the parameter mode isINOUT.static intparameterModeOutIndicates that the parameter mode isOUT.static intparameterModeUnknownIndicates that the parameter mode is not known.static intparameterNoNullsIndicates that a parameter is not permitted to beNULL.static intparameterNullableIndicates that a parameter is permitted to beNULL.static intparameterNullableUnknownIndicates that whether a parameter is allowed to benullor not is not known. -
Method Summary
Modifier and Type Method Description StringgetParameterClassName(int paramIndex)Gets the fully-qualified name of the Java class which should be passed as a parameter to the methodPreparedStatement.setObject.intgetParameterCount()Gets the number of parameters in thePreparedStatementfor which thisParameterMetaDatacontains information.intgetParameterMode(int paramIndex)Gets the mode of the specified parameter.intgetParameterType(int paramIndex)Gets the SQL type of a specified parameter.StringgetParameterTypeName(int paramIndex)Gets the database-specific type name of a specified parameter.intgetPrecision(int paramIndex)Gets the number of decimal digits for a specified parameter.intgetScale(int paramIndex)Gets the number of digits after the decimal point for a specified parameter.intisNullable(int paramIndex)Gets whethernullvalues are allowed for the specified parameter.booleanisSigned(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 parameterModeInIndicates that the parameter mode isIN.- See Also:
- Constant Field Values
-
parameterModeInOut
static final int parameterModeInOutIndicates that the parameter mode isINOUT.- See Also:
- Constant Field Values
-
parameterModeOut
static final int parameterModeOutIndicates that the parameter mode isOUT.- See Also:
- Constant Field Values
-
parameterModeUnknown
static final int parameterModeUnknownIndicates that the parameter mode is not known.- See Also:
- Constant Field Values
-
parameterNoNulls
static final int parameterNoNullsIndicates that a parameter is not permitted to beNULL.- See Also:
- Constant Field Values
-
parameterNullable
static final int parameterNullableIndicates that a parameter is permitted to beNULL.- See Also:
- Constant Field Values
-
parameterNullableUnknown
static final int parameterNullableUnknownIndicates that whether a parameter is allowed to benullor not is not known.- See Also:
- Constant Field Values
-
-
Method Details
-
getParameterClassName
Gets the fully-qualified name of the Java class which should be passed as a parameter to the methodPreparedStatement.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
Gets the number of parameters in thePreparedStatementfor which thisParameterMetaDatacontains information.- Returns:
- the number of parameters.
- Throws:
SQLException- if a database error happens.
-
getParameterMode
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
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
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
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.
0if the parameter is not a numeric type. - Throws:
SQLException- if a database error happens.
-
getScale
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.
0if the parameter is not a numeric type. - Throws:
SQLException- if a database error happens.
-
isNullable
Gets whethernullvalues 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
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:
trueif values can be signed numbers for this parameter,falseotherwise.- Throws:
SQLException- if a database error happens.
-