Path: blob/master/src/java.sql/share/classes/java/sql/ParameterMetaData.java
41153 views
/*1* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.sql;2627/**28* An object that can be used to get information about the types29* and properties for each parameter marker in a30* {@code PreparedStatement} object. For some queries and driver31* implementations, the data that would be returned by a {@code ParameterMetaData}32* object may not be available until the {@code PreparedStatement} has33* been executed.34*<p>35*Some driver implementations may not be able to provide information about the36*types and properties for each parameter marker in a {@code CallableStatement}37*object.38*39* @since 1.440*/4142public interface ParameterMetaData extends Wrapper {4344/**45* Retrieves the number of parameters in the {@code PreparedStatement}46* object for which this {@code ParameterMetaData} object contains47* information.48*49* @return the number of parameters50* @throws SQLException if a database access error occurs51* @since 1.452*/53int getParameterCount() throws SQLException;5455/**56* Retrieves whether null values are allowed in the designated parameter.57*58* @param param the first parameter is 1, the second is 2, ...59* @return the nullability status of the given parameter; one of60* {@code ParameterMetaData.parameterNoNulls},61* {@code ParameterMetaData.parameterNullable}, or62* {@code ParameterMetaData.parameterNullableUnknown}63* @throws SQLException if a database access error occurs64* @since 1.465*/66int isNullable(int param) throws SQLException;6768/**69* The constant indicating that a70* parameter will not allow {@code NULL} values.71*/72int parameterNoNulls = 0;7374/**75* The constant indicating that a76* parameter will allow {@code NULL} values.77*/78int parameterNullable = 1;7980/**81* The constant indicating that the82* nullability of a parameter is unknown.83*/84int parameterNullableUnknown = 2;8586/**87* Retrieves whether values for the designated parameter can be signed numbers.88*89* @param param the first parameter is 1, the second is 2, ...90* @return {@code true} if so; {@code false} otherwise91* @throws SQLException if a database access error occurs92* @since 1.493*/94boolean isSigned(int param) throws SQLException;9596/**97* Retrieves the designated parameter's specified column size.98*99* <P>The returned value represents the maximum column size for the given parameter.100* For numeric data, this is the maximum precision. For character data, this is the length in characters.101* For datetime datatypes, this is the length in characters of the String representation (assuming the102* maximum allowed precision of the fractional seconds component). For binary data, this is the length in bytes. For the ROWID datatype,103* this is the length in bytes. 0 is returned for data types where the104* column size is not applicable.105*106* @param param the first parameter is 1, the second is 2, ...107* @return precision108* @throws SQLException if a database access error occurs109* @since 1.4110*/111int getPrecision(int param) throws SQLException;112113/**114* Retrieves the designated parameter's number of digits to right of the decimal point.115* 0 is returned for data types where the scale is not applicable.116*117* @param param the first parameter is 1, the second is 2, ...118* @return scale119* @throws SQLException if a database access error occurs120* @since 1.4121*/122int getScale(int param) throws SQLException;123124/**125* Retrieves the designated parameter's SQL type.126*127* @param param the first parameter is 1, the second is 2, ...128* @return SQL type from {@code java.sql.Types}129* @throws SQLException if a database access error occurs130* @since 1.4131* @see Types132*/133int getParameterType(int param) throws SQLException;134135/**136* Retrieves the designated parameter's database-specific type name.137*138* @param param the first parameter is 1, the second is 2, ...139* @return type the name used by the database. If the parameter type is140* a user-defined type, then a fully-qualified type name is returned.141* @throws SQLException if a database access error occurs142* @since 1.4143*/144String getParameterTypeName(int param) throws SQLException;145146147/**148* Retrieves the fully-qualified name of the Java class whose instances149* should be passed to the method {@code PreparedStatement.setObject}.150*151* @param param the first parameter is 1, the second is 2, ...152* @return the fully-qualified name of the class in the Java programming153* language that would be used by the method154* {@code PreparedStatement.setObject} to set the value155* in the specified parameter. This is the class name used156* for custom mapping.157* @throws SQLException if a database access error occurs158* @since 1.4159*/160String getParameterClassName(int param) throws SQLException;161162/**163* The constant indicating that the mode of the parameter is unknown.164*/165int parameterModeUnknown = 0;166167/**168* The constant indicating that the parameter's mode is IN.169*/170int parameterModeIn = 1;171172/**173* The constant indicating that the parameter's mode is INOUT.174*/175int parameterModeInOut = 2;176177/**178* The constant indicating that the parameter's mode is OUT.179*/180int parameterModeOut = 4;181182/**183* Retrieves the designated parameter's mode.184*185* @param param the first parameter is 1, the second is 2, ...186* @return mode of the parameter; one of187* {@code ParameterMetaData.parameterModeIn},188* {@code ParameterMetaData.parameterModeOut}, or189* {@code ParameterMetaData.parameterModeInOut}190* {@code ParameterMetaData.parameterModeUnknown}.191* @throws SQLException if a database access error occurs192* @since 1.4193*/194int getParameterMode(int param) throws SQLException;195}196197198