1 /*
2 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
398 * @param targetSqlType the SQL type (as defined in java.sql.Types) to be
399 * sent to the database
400 * @exception SQLException if parameterIndex does not correspond to a parameter
401 * marker in the SQL statement; if a database access error occurs or this
402 * method is called on a closed PreparedStatement
403 * @exception SQLFeatureNotSupportedException if
404 * the JDBC driver does not support the specified targetSqlType
405 * @see Types
406 */
407 void setObject(int parameterIndex, Object x, int targetSqlType)
408 throws SQLException;
409
410 /**
411 * <p>Sets the value of the designated parameter using the given object.
412 *
413 * <p>The JDBC specification specifies a standard mapping from
414 * Java <code>Object</code> types to SQL types. The given argument
415 * will be converted to the corresponding SQL type before being
416 * sent to the database.
417 *
418 * <p>Note that this method may be used to pass datatabase-
419 * specific abstract data types, by using a driver-specific Java
420 * type.
421 *
422 * If the object is of a class implementing the interface <code>SQLData</code>,
423 * the JDBC driver should call the method <code>SQLData.writeSQL</code>
424 * to write it to the SQL data stream.
425 * If, on the other hand, the object is of a class implementing
426 * <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, <code>NClob</code>,
427 * <code>Struct</code>, <code>java.net.URL</code>, <code>RowId</code>, <code>SQLXML</code>
428 * or <code>Array</code>, the driver should pass it to the database as a
429 * value of the corresponding SQL type.
430 * <P>
431 *<b>Note:</b> Not all databases allow for a non-typed Null to be sent to
432 * the backend. For maximum portability, the <code>setNull</code> or the
433 * <code>setObject(int parameterIndex, Object x, int sqlType)</code>
434 * method should be used
435 * instead of <code>setObject(int parameterIndex, Object x)</code>.
436 *<p>
437 * <b>Note:</b> This method throws an exception if there is an ambiguity, for example, if the
438 * object is of a class implementing more than one of the interfaces named above.
821 * generated when the <code>PreparedStatement</code> is executed.
822 *This method differs from the <code>setCharacterStream (int, Reader, int)</code> method
823 * because it informs the driver that the parameter value should be sent to
824 * the server as a <code>CLOB</code>. When the <code>setCharacterStream</code> method is used, the
825 * driver may have to do extra work to determine whether the parameter
826 * data should be sent to the server as a <code>LONGVARCHAR</code> or a <code>CLOB</code>
827 * @param parameterIndex index of the first parameter is 1, the second is 2, ...
828 * @param reader An object that contains the data to set the parameter value to.
829 * @param length the number of characters in the parameter data.
830 * @throws SQLException if parameterIndex does not correspond to a parameter
831 * marker in the SQL statement; if a database access error occurs; this method is called on
832 * a closed <code>PreparedStatement</code> or if the length specified is less than zero.
833 *
834 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
835 * @since 1.6
836 */
837 void setClob(int parameterIndex, Reader reader, long length)
838 throws SQLException;
839
840 /**
841 * Sets the designated parameter to a <code>InputStream</code> object. The inputstream must contain the number
842 * of characters specified by length otherwise a <code>SQLException</code> will be
843 * generated when the <code>PreparedStatement</code> is executed.
844 * This method differs from the <code>setBinaryStream (int, InputStream, int)</code>
845 * method because it informs the driver that the parameter value should be
846 * sent to the server as a <code>BLOB</code>. When the <code>setBinaryStream</code> method is used,
847 * the driver may have to do extra work to determine whether the parameter
848 * data should be sent to the server as a <code>LONGVARBINARY</code> or a <code>BLOB</code>
849 * @param parameterIndex index of the first parameter is 1,
850 * the second is 2, ...
851 * @param inputStream An object that contains the data to set the parameter
852 * value to.
853 * @param length the number of bytes in the parameter data.
854 * @throws SQLException if parameterIndex does not correspond to a parameter
855 * marker in the SQL statement; if a database access error occurs;
856 * this method is called on a closed <code>PreparedStatement</code>;
857 * if the length specified
858 * is less than zero or if the number of bytes in the inputstream does not match
859 * the specified length.
860 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
861 *
862 * @since 1.6
863 */
864 void setBlob(int parameterIndex, InputStream inputStream, long length)
865 throws SQLException;
866 /**
867 * Sets the designated parameter to a <code>Reader</code> object. The reader must contain the number
868 * of characters specified by length otherwise a <code>SQLException</code> will be
869 * generated when the <code>PreparedStatement</code> is executed.
870 * This method differs from the <code>setCharacterStream (int, Reader, int)</code> method
871 * because it informs the driver that the parameter value should be sent to
872 * the server as a <code>NCLOB</code>. When the <code>setCharacterStream</code> method is used, the
873 * driver may have to do extra work to determine whether the parameter
874 * data should be sent to the server as a <code>LONGNVARCHAR</code> or a <code>NCLOB</code>
875 * @param parameterIndex index of the first parameter is 1, the second is 2, ...
876 * @param reader An object that contains the data to set the parameter value to.
877 * @param length the number of characters in the parameter data.
878 * @throws SQLException if parameterIndex does not correspond to a parameter
|
1 /*
2 * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
398 * @param targetSqlType the SQL type (as defined in java.sql.Types) to be
399 * sent to the database
400 * @exception SQLException if parameterIndex does not correspond to a parameter
401 * marker in the SQL statement; if a database access error occurs or this
402 * method is called on a closed PreparedStatement
403 * @exception SQLFeatureNotSupportedException if
404 * the JDBC driver does not support the specified targetSqlType
405 * @see Types
406 */
407 void setObject(int parameterIndex, Object x, int targetSqlType)
408 throws SQLException;
409
410 /**
411 * <p>Sets the value of the designated parameter using the given object.
412 *
413 * <p>The JDBC specification specifies a standard mapping from
414 * Java <code>Object</code> types to SQL types. The given argument
415 * will be converted to the corresponding SQL type before being
416 * sent to the database.
417 *
418 * <p>Note that this method may be used to pass database-
419 * specific abstract data types, by using a driver-specific Java
420 * type.
421 *
422 * If the object is of a class implementing the interface <code>SQLData</code>,
423 * the JDBC driver should call the method <code>SQLData.writeSQL</code>
424 * to write it to the SQL data stream.
425 * If, on the other hand, the object is of a class implementing
426 * <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, <code>NClob</code>,
427 * <code>Struct</code>, <code>java.net.URL</code>, <code>RowId</code>, <code>SQLXML</code>
428 * or <code>Array</code>, the driver should pass it to the database as a
429 * value of the corresponding SQL type.
430 * <P>
431 *<b>Note:</b> Not all databases allow for a non-typed Null to be sent to
432 * the backend. For maximum portability, the <code>setNull</code> or the
433 * <code>setObject(int parameterIndex, Object x, int sqlType)</code>
434 * method should be used
435 * instead of <code>setObject(int parameterIndex, Object x)</code>.
436 *<p>
437 * <b>Note:</b> This method throws an exception if there is an ambiguity, for example, if the
438 * object is of a class implementing more than one of the interfaces named above.
821 * generated when the <code>PreparedStatement</code> is executed.
822 *This method differs from the <code>setCharacterStream (int, Reader, int)</code> method
823 * because it informs the driver that the parameter value should be sent to
824 * the server as a <code>CLOB</code>. When the <code>setCharacterStream</code> method is used, the
825 * driver may have to do extra work to determine whether the parameter
826 * data should be sent to the server as a <code>LONGVARCHAR</code> or a <code>CLOB</code>
827 * @param parameterIndex index of the first parameter is 1, the second is 2, ...
828 * @param reader An object that contains the data to set the parameter value to.
829 * @param length the number of characters in the parameter data.
830 * @throws SQLException if parameterIndex does not correspond to a parameter
831 * marker in the SQL statement; if a database access error occurs; this method is called on
832 * a closed <code>PreparedStatement</code> or if the length specified is less than zero.
833 *
834 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
835 * @since 1.6
836 */
837 void setClob(int parameterIndex, Reader reader, long length)
838 throws SQLException;
839
840 /**
841 * Sets the designated parameter to a <code>InputStream</code> object.
842 * The {@code Inputstream} must contain the number
843 * of characters specified by length otherwise a <code>SQLException</code> will be
844 * generated when the <code>PreparedStatement</code> is executed.
845 * This method differs from the <code>setBinaryStream (int, InputStream, int)</code>
846 * method because it informs the driver that the parameter value should be
847 * sent to the server as a <code>BLOB</code>. When the <code>setBinaryStream</code> method is used,
848 * the driver may have to do extra work to determine whether the parameter
849 * data should be sent to the server as a <code>LONGVARBINARY</code> or a <code>BLOB</code>
850 * @param parameterIndex index of the first parameter is 1,
851 * the second is 2, ...
852 * @param inputStream An object that contains the data to set the parameter
853 * value to.
854 * @param length the number of bytes in the parameter data.
855 * @throws SQLException if parameterIndex does not correspond to a parameter
856 * marker in the SQL statement; if a database access error occurs;
857 * this method is called on a closed <code>PreparedStatement</code>;
858 * if the length specified
859 * is less than zero or if the number of bytes in the {@code InputStream} does not match
860 * the specified length.
861 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
862 *
863 * @since 1.6
864 */
865 void setBlob(int parameterIndex, InputStream inputStream, long length)
866 throws SQLException;
867 /**
868 * Sets the designated parameter to a <code>Reader</code> object. The reader must contain the number
869 * of characters specified by length otherwise a <code>SQLException</code> will be
870 * generated when the <code>PreparedStatement</code> is executed.
871 * This method differs from the <code>setCharacterStream (int, Reader, int)</code> method
872 * because it informs the driver that the parameter value should be sent to
873 * the server as a <code>NCLOB</code>. When the <code>setCharacterStream</code> method is used, the
874 * driver may have to do extra work to determine whether the parameter
875 * data should be sent to the server as a <code>LONGNVARCHAR</code> or a <code>NCLOB</code>
876 * @param parameterIndex index of the first parameter is 1, the second is 2, ...
877 * @param reader An object that contains the data to set the parameter value to.
878 * @param length the number of characters in the parameter data.
879 * @throws SQLException if parameterIndex does not correspond to a parameter
|