001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package java.sql;
019:
020: /**
021: * An interface used to get information about the types and properties of
022: * parameters in a PreparedStatement object.
023: */
024: public interface ParameterMetaData {
025:
026: /**
027: * Indicates that the parameter mode is IN.
028: */
029: public static final int parameterModeIn = 1;
030:
031: /**
032: * Indicates that the parameter mode is INOUT.
033: */
034: public static final int parameterModeInOut = 2;
035:
036: /**
037: * Indicates that the parameter mode is OUT.
038: */
039: public static final int parameterModeOut = 4;
040:
041: /**
042: * Indicates that the parameter mode is not known.
043: */
044: public static final int parameterModeUnknown = 0;
045:
046: /**
047: * Indicates that a parameter is not permitted to be NULL.
048: */
049: public static final int parameterNoNulls = 0;
050:
051: /**
052: * Indicates that a parameter is permitted to be NULL.
053: */
054: public static final int parameterNullable = 1;
055:
056: /**
057: * Indicates that whether a parameter is allowed to be null or not is not
058: * known.
059: */
060: public static final int parameterNullableUnknown = 2;
061:
062: /**
063: * Gets the fully-qualified name of the Java class which should be passed as
064: * a parameter to the method <code>PreparedStatement.setObject</code>.
065: *
066: * @param paramIndex
067: * the index number of the parameter, where the first parameter
068: * has an index of 1
069: * @return a String with the fully qualified Java class name of the
070: * parameter with the specified index. This class name is used for
071: * custom mapping.
072: * @throws SQLException
073: * if a database error happens
074: */
075: public String getParameterClassName(int paramIndex)
076: throws SQLException;
077:
078: /**
079: * Gets the number of parameters in the PreparedStatement for which this
080: * ParameterMetaData contains information.
081: *
082: * @return the number of parameters as an int
083: * @throws SQLException
084: * if a database error happens
085: */
086: public int getParameterCount() throws SQLException;
087:
088: /**
089: * Gets the mode of the specified parameter.
090: *
091: * @param paramIndex
092: * the index number of the parameter, where the first parameter
093: * has an index of 1
094: * @return the parameters mode. Can be: ParameterMetaData.parameterModeIn,
095: * ParameterMetaData.parameterModeOut,
096: * ParameterMetaData.parameterModeInOut or
097: * ParameterMetaData.parameterModeUnknown.
098: * @throws SQLException
099: * if a database error happens
100: */
101: public int getParameterMode(int paramIndex) throws SQLException;
102:
103: /**
104: * Gets the SQL type of a specified parameter.
105: *
106: * @param paramIndex
107: * the index number of the parameter, where the first parameter
108: * has an index of 1
109: * @return the type of the parameter - an SQL type as defined in
110: * java.sql.Types.
111: * @throws SQLException
112: * if a database error happens
113: */
114: public int getParameterType(int paramIndex) throws SQLException;
115:
116: /**
117: * Gets the database-specific type name of a specified parameter.
118: *
119: * @param paramIndex
120: * the index number of the parameter, where the first parameter
121: * has an index of 1
122: * @return the type name for the parameter as used by the database. A
123: * fully-qualified name is returned if the parameter is a User
124: * Defined Type.
125: * @throws SQLException
126: * if a database error happens
127: */
128: public String getParameterTypeName(int paramIndex)
129: throws SQLException;
130:
131: /**
132: * Gets the number of decimal digits for a specified parameter.
133: *
134: * @param paramIndex
135: * the index number of the parameter, where the first parameter
136: * has an index of 1
137: * @return the number of decimal digits ("the precision") for the parameter.
138: * 0 if the parameter is not a numeric type.
139: * @throws SQLException
140: * if a database error happens
141: */
142: public int getPrecision(int paramIndex) throws SQLException;
143:
144: /**
145: * Gets the number of digits after the decimal point for a specified
146: * parameter.
147: *
148: * @param paramIndex
149: * the index number of the parameter, where the first parameter
150: * has an index of 1
151: * @return the number of digits after the decimal point ("the scale") for
152: * the parameter. 0 if the parameter is not a numeric type.
153: * @throws SQLException
154: * if a database error happens
155: */
156: public int getScale(int paramIndex) throws SQLException;
157:
158: /**
159: * Gets whether null values are allowed for the specified parameter.
160: *
161: * @param paramIndex
162: * the index number of the parameter, where the first parameter
163: * has an index of 1
164: * @return indicator of nullability, can be:
165: * ParameterMetaData.parameterNoNulls,
166: * ParameterMetaData.parameterNullable, or
167: * ParameterMetaData.parameterNullableUnknown
168: * @throws SQLException
169: * if a database error is encountered
170: */
171: public int isNullable(int paramIndex) throws SQLException;
172:
173: /**
174: * Gets whether values for the specified parameter can be signed numbers.
175: *
176: * @param paramIndex
177: * the index number of the parameter, where the first parameter
178: * has an index of 1
179: * @return true if values can be signed numbers for this parameter, false
180: * otherwise.
181: * @throws SQLException
182: * if a database error happens
183: */
184: public boolean isSigned(int paramIndex) throws SQLException;
185: }
|