2499 lines · 117.5 KB · Java
RawDownload
/* * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.  Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package java.sql; import java.math.BigDecimal;import java.util.Calendar;import java.io.Reader;import java.io.InputStream; /** * The interface used to execute SQL stored procedures.  The JDBC API * provides a stored procedure SQL escape syntax that allows stored procedures * to be called in a standard way for all RDBMSs. This escape syntax has one * form that includes a result parameter and one that does not. If used, the result * parameter must be registered as an OUT parameter. The other parameters * can be used for input, output or both. Parameters are referred to * sequentially, by number, with the first parameter being 1. * <PRE> *   {?= call &lt;procedure-name&gt;[(&lt;arg1&gt;,&lt;arg2&gt;, ...)]} *   {call &lt;procedure-name&gt;[(&lt;arg1&gt;,&lt;arg2&gt;, ...)]} * </PRE> * <P> * IN parameter values are set using the <code>set</code> methods inherited from * {@link PreparedStatement}.  The type of all OUT parameters must be * registered prior to executing the stored procedure; their values * are retrieved after execution via the <code>get</code> methods provided here. * <P> * A <code>CallableStatement</code> can return one {@link ResultSet} object or * multiple <code>ResultSet</code> objects.  Multiple * <code>ResultSet</code> objects are handled using operations * inherited from {@link Statement}. * <P> * For maximum portability, a call's <code>ResultSet</code> objects and * update counts should be processed prior to getting the values of output * parameters. * <P> * * @see Connection#prepareCall * @see ResultSet */ public interface CallableStatement extends PreparedStatement {     /**     * Registers the OUT parameter in ordinal position     * <code>parameterIndex</code> to the JDBC type     * <code>sqlType</code>.  All OUT parameters must be registered     * before a stored procedure is executed.     * <p>     * The JDBC type specified by <code>sqlType</code> for an OUT     * parameter determines the Java type that must be used     * in the <code>get</code> method to read the value of that parameter.     * <p>     * If the JDBC type expected to be returned to this output parameter     * is specific to this particular database, <code>sqlType</code>     * should be <code>java.sql.Types.OTHER</code>.  The method     * {@link #getObject} retrieves the value.     *     * @param parameterIndex the first parameter is 1, the second is 2,     *        and so on     * @param sqlType the JDBC type code defined by <code>java.sql.Types</code>.     *        If the parameter is of JDBC type <code>NUMERIC</code>     *        or <code>DECIMAL</code>, the version of     *        <code>registerOutParameter</code> that accepts a scale value     *        should be used.     *     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @exception SQLFeatureNotSupportedException if <code>sqlType</code> is     * a <code>ARRAY</code>, <code>BLOB</code>, <code>CLOB</code>,     * <code>DATALINK</code>, <code>JAVA_OBJECT</code>, <code>NCHAR</code>,     * <code>NCLOB</code>, <code>NVARCHAR</code>, <code>LONGNVARCHAR</code>,     *  <code>REF</code>, <code>ROWID</code>, <code>SQLXML</code>     * or  <code>STRUCT</code> data type and the JDBC driver does not support     * this data type     * @see Types     */    void registerOutParameter(int parameterIndex, int sqlType)        throws SQLException;     /**     * Registers the parameter in ordinal position     * <code>parameterIndex</code> to be of JDBC type     * <code>sqlType</code>. All OUT parameters must be registered     * before a stored procedure is executed.     * <p>     * The JDBC type specified by <code>sqlType</code> for an OUT     * parameter determines the Java type that must be used     * in the <code>get</code> method to read the value of that parameter.     * <p>     * This version of <code>registerOutParameter</code> should be     * used when the parameter is of JDBC type <code>NUMERIC</code>     * or <code>DECIMAL</code>.     *     * @param parameterIndex the first parameter is 1, the second is 2,     * and so on     * @param sqlType the SQL type code defined by <code>java.sql.Types</code>.     * @param scale the desired number of digits to the right of the     * decimal point.  It must be greater than or equal to zero.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @exception SQLFeatureNotSupportedException if <code>sqlType</code> is     * a <code>ARRAY</code>, <code>BLOB</code>, <code>CLOB</code>,     * <code>DATALINK</code>, <code>JAVA_OBJECT</code>, <code>NCHAR</code>,     * <code>NCLOB</code>, <code>NVARCHAR</code>, <code>LONGNVARCHAR</code>,     *  <code>REF</code>, <code>ROWID</code>, <code>SQLXML</code>     * or  <code>STRUCT</code> data type and the JDBC driver does not support     * this data type     * @see Types     */    void registerOutParameter(int parameterIndex, int sqlType, int scale)        throws SQLException;     /**     * Retrieves whether the last OUT parameter read had the value of     * SQL <code>NULL</code>.  Note that this method should be called only after     * calling a getter method; otherwise, there is no value to use in     * determining whether it is <code>null</code> or not.     *     * @return <code>true</code> if the last parameter read was SQL     * <code>NULL</code>; <code>false</code> otherwise     * @exception SQLException if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     */    boolean wasNull() throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>CHAR</code>,     * <code>VARCHAR</code>, or <code>LONGVARCHAR</code> parameter as a     * <code>String</code> in the Java programming language.     * <p>     * For the fixed-length type JDBC <code>CHAR</code>,     * the <code>String</code> object     * returned has exactly the same value the SQL     * <code>CHAR</code> value had in the     * database, including any padding added by the database.     *     * @param parameterIndex the first parameter is 1, the second is 2,     * and so on     * @return the parameter value. If the value is SQL <code>NULL</code>,     *         the result     *         is <code>null</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setString     */    String getString(int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>BIT</code>     * or <code>BOOLEAN</code> parameter as a     * <code>boolean</code> in the Java programming language.     *     * @param parameterIndex the first parameter is 1, the second is 2,     *        and so on     * @return the parameter value.  If the value is SQL <code>NULL</code>,     *         the result is <code>false</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setBoolean     */    boolean getBoolean(int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>TINYINT</code> parameter     * as a <code>byte</code> in the Java programming language.     *     * @param parameterIndex the first parameter is 1, the second is 2,     * and so on     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result     * is <code>0</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setByte     */    byte getByte(int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>SMALLINT</code> parameter     * as a <code>short</code> in the Java programming language.     *     * @param parameterIndex the first parameter is 1, the second is 2,     * and so on     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result     * is <code>0</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setShort     */    short getShort(int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>INTEGER</code> parameter     * as an <code>int</code> in the Java programming language.     *     * @param parameterIndex the first parameter is 1, the second is 2,     * and so on     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result     * is <code>0</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setInt     */    int getInt(int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>BIGINT</code> parameter     * as a <code>long</code> in the Java programming language.     *     * @param parameterIndex the first parameter is 1, the second is 2,     * and so on     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result     * is <code>0</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setLong     */    long getLong(int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>FLOAT</code> parameter     * as a <code>float</code> in the Java programming language.     *     * @param parameterIndex the first parameter is 1, the second is 2,     *        and so on     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result     *         is <code>0</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setFloat     */    float getFloat(int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>DOUBLE</code> parameter as a <code>double</code>     * in the Java programming language.     * @param parameterIndex the first parameter is 1, the second is 2,     *        and so on     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result     *         is <code>0</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setDouble     */    double getDouble(int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>NUMERIC</code> parameter as a     * <code>java.math.BigDecimal</code> object with <i>scale</i> digits to     * the right of the decimal point.     * @param parameterIndex the first parameter is 1, the second is 2,     *        and so on     * @param scale the number of digits to the right of the decimal point     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result     *         is <code>null</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support     * this method     * @deprecated use <code>getBigDecimal(int parameterIndex)</code>     *             or <code>getBigDecimal(String parameterName)</code>     * @see #setBigDecimal     */    BigDecimal getBigDecimal(int parameterIndex, int scale)        throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>BINARY</code> or     * <code>VARBINARY</code> parameter as an array of <code>byte</code>     * values in the Java programming language.     * @param parameterIndex the first parameter is 1, the second is 2,     *        and so on     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result     *         is <code>null</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setBytes     */    byte[] getBytes(int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>DATE</code> parameter as a     * <code>java.sql.Date</code> object.     * @param parameterIndex the first parameter is 1, the second is 2,     *        and so on     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result     *         is <code>null</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setDate     */    java.sql.Date getDate(int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>TIME</code> parameter as a     * <code>java.sql.Time</code> object.     *     * @param parameterIndex the first parameter is 1, the second is 2,     *        and so on     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result     *         is <code>null</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setTime     */    java.sql.Time getTime(int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>TIMESTAMP</code> parameter as a     * <code>java.sql.Timestamp</code> object.     *     * @param parameterIndex the first parameter is 1, the second is 2,     *        and so on     * @return the parameter value.  If the value is SQL <code>NULL</code>, the result     *         is <code>null</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setTimestamp     */    java.sql.Timestamp getTimestamp(int parameterIndex)        throws SQLException;     //----------------------------------------------------------------------    // Advanced features:      /**     * Retrieves the value of the designated parameter as an <code>Object</code>     * in the Java programming language. If the value is an SQL <code>NULL</code>,     * the driver returns a Java <code>null</code>.     * <p>     * This method returns a Java object whose type corresponds to the JDBC     * type that was registered for this parameter using the method     * <code>registerOutParameter</code>.  By registering the target JDBC     * type as <code>java.sql.Types.OTHER</code>, this method can be used     * to read database-specific abstract data types.     *     * @param parameterIndex the first parameter is 1, the second is 2,     *        and so on     * @return A <code>java.lang.Object</code> holding the OUT parameter value     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see Types     * @see #setObject     */    Object getObject(int parameterIndex) throws SQLException;      //--------------------------JDBC 2.0-----------------------------     /**     * Retrieves the value of the designated JDBC <code>NUMERIC</code> parameter as a     * <code>java.math.BigDecimal</code> object with as many digits to the     * right of the decimal point as the value contains.     * @param parameterIndex the first parameter is 1, the second is 2,     * and so on     * @return the parameter value in full precision.  If the value is     * SQL <code>NULL</code>, the result is <code>null</code>.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @see #setBigDecimal     * @since 1.2     */    BigDecimal getBigDecimal(int parameterIndex) throws SQLException;     /**     * Returns an object representing the value of OUT parameter     * <code>parameterIndex</code> and uses <code>map</code> for the custom     * mapping of the parameter value.     * <p>     * This method returns a Java object whose type corresponds to the     * JDBC type that was registered for this parameter using the method     * <code>registerOutParameter</code>.  By registering the target     * JDBC type as <code>java.sql.Types.OTHER</code>, this method can     * be used to read database-specific abstract data types.     * @param parameterIndex the first parameter is 1, the second is 2, and so on     * @param map the mapping from SQL type names to Java classes     * @return a <code>java.lang.Object</code> holding the OUT parameter value     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support     * this method     * @see #setObject     * @since 1.2     */    Object getObject(int parameterIndex, java.util.Map<String,Class<?>> map)        throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>REF(&lt;structured-type&gt;)</code>     * parameter as a {@link java.sql.Ref} object in the Java programming language.     * @param parameterIndex the first parameter is 1, the second is 2,     * and so on     * @return the parameter value as a <code>Ref</code> object in the     * Java programming language.  If the value was SQL <code>NULL</code>, the value     * <code>null</code> is returned.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support     * this method     * @since 1.2     */    Ref getRef (int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>BLOB</code> parameter as a     * {@link java.sql.Blob} object in the Java programming language.     * @param parameterIndex the first parameter is 1, the second is 2, and so on     * @return the parameter value as a <code>Blob</code> object in the     * Java programming language.  If the value was SQL <code>NULL</code>, the value     * <code>null</code> is returned.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support     * this method     * @since 1.2     */    Blob getBlob (int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>CLOB</code> parameter as a     * <code>java.sql.Clob</code> object in the Java programming language.     * @param parameterIndex the first parameter is 1, the second is 2, and     * so on     * @return the parameter value as a <code>Clob</code> object in the     * Java programming language.  If the value was SQL <code>NULL</code>, the     * value <code>null</code> is returned.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support     * this method     * @since 1.2     */    Clob getClob (int parameterIndex) throws SQLException;     /**     *     * Retrieves the value of the designated JDBC <code>ARRAY</code> parameter as an     * {@link java.sql.Array} object in the Java programming language.     * @param parameterIndex the first parameter is 1, the second is 2, and     * so on     * @return the parameter value as an <code>Array</code> object in     * the Java programming language.  If the value was SQL <code>NULL</code>, the     * value <code>null</code> is returned.     * @exception SQLException if the parameterIndex is not valid;     * if a database access error occurs or     * this method is called on a closed <code>CallableStatement</code>     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support     * this method     * @since 1.2     */    Array getArray (int parameterIndex) throws SQLException;     /**     * Retrieves the value of the designated JDBC <code>DATE</code> parameter as a     * <code>java.sql.Date</code> object, using

Lines 1–500 of 2499.