Clob.java revision 0
0N/A * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Sun in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A * The mapping in the Java<sup><font size=-2>TM</font></sup> programming language 0N/A * for the SQL <code>CLOB</code> type. 0N/A * An SQL <code>CLOB</code> is a built-in type 0N/A * that stores a Character Large Object as a column value in a row of 0N/A * By default drivers implement a <code>Clob</code> object using an SQL 0N/A * <code>locator(CLOB)</code>, which means that a <code>Clob</code> object 0N/A * contains a logical pointer to the SQL <code>CLOB</code> data rather than 0N/A * the data itself. A <code>Clob</code> object is valid for the duration 0N/A * of the transaction in which it was created. 0N/A * <P>The <code>Clob</code> interface provides methods for getting the 0N/A * length of an SQL <code>CLOB</code> (Character Large Object) value, 0N/A * for materializing a <code>CLOB</code> value on the client, and for 0N/A * searching for a substring or <code>CLOB</code> object within a 0N/A * <code>CLOB</code> value. 0N/A * Methods in the interfaces {@link ResultSet}, 0N/A * {@link CallableStatement}, and {@link PreparedStatement}, such as 0N/A * <code>getClob</code> and <code>setClob</code> allow a programmer to 0N/A * access an SQL <code>CLOB</code> value. In addition, this interface 0N/A * has methods for updating a <code>CLOB</code> value. 0N/A * All methods on the <code>Clob</code> interface must be fully implemented if the 0N/A * JDBC driver supports the data type. 0N/A * Retrieves the number of characters 0N/A * in the <code>CLOB</code> value 0N/A * designated by this <code>Clob</code> object. 0N/A * @return length of the <code>CLOB</code> in characters 0N/A * @exception SQLException if there is an error accessing the 0N/A * length of the <code>CLOB</code> value 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 0N/A * Retrieves a copy of the specified substring 0N/A * in the <code>CLOB</code> value 0N/A * designated by this <code>Clob</code> object. 0N/A * The substring begins at position 0N/A * <code>pos</code> and has up to <code>length</code> consecutive 0N/A * @param pos the first character of the substring to be extracted. 0N/A * The first character is at position 1. 0N/A * @param length the number of consecutive characters to be copied; 0N/A * the value for length must be 0 or greater 0N/A * @return a <code>String</code> that is the specified substring in 0N/A * the <code>CLOB</code> value designated by this <code>Clob</code> object 0N/A * @exception SQLException if there is an error accessing the 0N/A * <code>CLOB</code> value; if pos is less than 1 or length is 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 0N/A * Retrieves the <code>CLOB</code> value designated by this <code>Clob</code> 0N/A * object as a <code>java.io.Reader</code> object (or as a stream of 0N/A * @return a <code>java.io.Reader</code> object containing the 0N/A * <code>CLOB</code> data 0N/A * @exception SQLException if there is an error accessing the 0N/A * <code>CLOB</code> value 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 0N/A * @see #setCharacterStream 0N/A * Retrieves the <code>CLOB</code> value designated by this <code>Clob</code> 0N/A * object as an ascii stream. 0N/A * @return a <code>java.io.InputStream</code> object containing the 0N/A * <code>CLOB</code> data 0N/A * @exception SQLException if there is an error accessing the 0N/A * <code>CLOB</code> value 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 0N/A * @see #setAsciiStream 0N/A * Retrieves the character position at which the specified substring 0N/A * <code>searchstr</code> appears in the SQL <code>CLOB</code> value 0N/A * represented by this <code>Clob</code> object. The search 0N/A * begins at position <code>start</code>. 0N/A * @param searchstr the substring for which to search 0N/A * @param start the position at which to begin searching; the first position 0N/A * @return the position at which the substring appears or -1 if it is not 0N/A * present; the first position is 1 0N/A * @exception SQLException if there is an error accessing the 0N/A * <code>CLOB</code> value or if pos is less than 1 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 0N/A * Retrieves the character position at which the specified 0N/A * <code>Clob</code> object <code>searchstr</code> appears in this 0N/A * <code>Clob</code> object. The search begins at position 0N/A * <code>start</code>. 0N/A * @param searchstr the <code>Clob</code> object for which to search 0N/A * @param start the position at which to begin searching; the first 0N/A * @return the position at which the <code>Clob</code> object appears 0N/A * or -1 if it is not present; the first position is 1 0N/A * @exception SQLException if there is an error accessing the 0N/A * <code>CLOB</code> value or if start is less than 1 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 0N/A //---------------------------- jdbc 3.0 ----------------------------------- 0N/A * Writes the given Java <code>String</code> to the <code>CLOB</code> 0N/A * value that this <code>Clob</code> object designates at the position 0N/A * <code>pos</code>. The string will overwrite the existing characters 0N/A * in the <code>Clob</code> object starting at the position 0N/A * <code>pos</code>. If the end of the <code>Clob</code> value is reached 0N/A * while writing the given string, then the length of the <code>Clob</code> 0N/A * value will be increased to accomodate the extra characters. 0N/A * <b>Note:</b> If the value specified for <code>pos</code> 0N/A * is greater then the length+1 of the <code>CLOB</code> value then the 0N/A * behavior is undefined. Some JDBC drivers may throw a 0N/A * <code>SQLException</code> while other drivers may support this 0N/A * @param pos the position at which to start writing to the <code>CLOB</code> 0N/A * value that this <code>Clob</code> object represents; 0N/A * The first position is 1 0N/A * @param str the string to be written to the <code>CLOB</code> 0N/A * value that this <code>Clob</code> designates 0N/A * @return the number of characters written 0N/A * @exception SQLException if there is an error accessing the 0N/A * <code>CLOB</code> value or if pos is less than 1 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 0N/A * Writes <code>len</code> characters of <code>str</code>, starting 0N/A * at character <code>offset</code>, to the <code>CLOB</code> value 0N/A * that this <code>Clob</code> represents. The string will overwrite the existing characters 0N/A * in the <code>Clob</code> object starting at the position 0N/A * <code>pos</code>. If the end of the <code>Clob</code> value is reached 0N/A * while writing the given string, then the length of the <code>Clob</code> 0N/A * value will be increased to accomodate the extra characters. 0N/A * <b>Note:</b> If the value specified for <code>pos</code> 0N/A * is greater then the length+1 of the <code>CLOB</code> value then the 0N/A * behavior is undefined. Some JDBC drivers may throw a 0N/A * <code>SQLException</code> while other drivers may support this 0N/A * @param pos the position at which to start writing to this 0N/A * <code>CLOB</code> object; The first position is 1 0N/A * @param str the string to be written to the <code>CLOB</code> 0N/A * value that this <code>Clob</code> object represents 0N/A * @param offset the offset into <code>str</code> to start reading 0N/A * the characters to be written 0N/A * @param len the number of characters to be written 0N/A * @return the number of characters written 0N/A * @exception SQLException if there is an error accessing the 0N/A * <code>CLOB</code> value or if pos is less than 1 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 0N/A * Retrieves a stream to be used to write Ascii characters to the 0N/A * <code>CLOB</code> value that this <code>Clob</code> object represents, 0N/A * starting at position <code>pos</code>. Characters written to the stream 0N/A * will overwrite the existing characters 0N/A * in the <code>Clob</code> object starting at the position 0N/A * <code>pos</code>. If the end of the <code>Clob</code> value is reached 0N/A * while writing characters to the stream, then the length of the <code>Clob</code> 0N/A * value will be increased to accomodate the extra characters. 0N/A * <b>Note:</b> If the value specified for <code>pos</code> 0N/A * is greater then the length+1 of the <code>CLOB</code> value then the 0N/A * behavior is undefined. Some JDBC drivers may throw a 0N/A * <code>SQLException</code> while other drivers may support this 0N/A * @param pos the position at which to start writing to this 0N/A * <code>CLOB</code> object; The first position is 1 0N/A * @return the stream to which ASCII encoded characters can be written 0N/A * @exception SQLException if there is an error accessing the 0N/A * <code>CLOB</code> value or if pos is less than 1 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 0N/A * @see #getAsciiStream 0N/A * Retrieves a stream to be used to write a stream of Unicode characters 0N/A * to the <code>CLOB</code> value that this <code>Clob</code> object 0N/A * represents, at position <code>pos</code>. Characters written to the stream 0N/A * will overwrite the existing characters 0N/A * in the <code>Clob</code> object starting at the position 0N/A * <code>pos</code>. If the end of the <code>Clob</code> value is reached 0N/A * while writing characters to the stream, then the length of the <code>Clob</code> 0N/A * value will be increased to accomodate the extra characters. 0N/A * <b>Note:</b> If the value specified for <code>pos</code> 0N/A * is greater then the length+1 of the <code>CLOB</code> value then the 0N/A * behavior is undefined. Some JDBC drivers may throw a 0N/A * <code>SQLException</code> while other drivers may support this 0N/A * @param pos the position at which to start writing to the 0N/A * <code>CLOB</code> value; The first position is 1 0N/A * @return a stream to which Unicode encoded characters can be written 0N/A * @exception SQLException if there is an error accessing the 0N/A * <code>CLOB</code> value or if pos is less than 1 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 0N/A * @see #getCharacterStream 0N/A * Truncates the <code>CLOB</code> value that this <code>Clob</code> 0N/A * designates to have a length of <code>len</code> 0N/A * <b>Note:</b> If the value specified for <code>pos</code> 0N/A * is greater then the length+1 of the <code>CLOB</code> value then the 0N/A * behavior is undefined. Some JDBC drivers may throw a 0N/A * <code>SQLException</code> while other drivers may support this 0N/A * @param len the length, in characters, to which the <code>CLOB</code> value 0N/A * should be truncated 0N/A * @exception SQLException if there is an error accessing the 0N/A * <code>CLOB</code> value or if len is less than 0 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 0N/A * This method frees the <code>Clob</code> object and releases the resources the resources 0N/A * that it holds. The object is invalid once the <code>free</code> method 0N/A * After <code>free</code> has been called, any attempt to invoke a 0N/A * method other than <code>free</code> will result in a <code>SQLException</code> 0N/A * being thrown. If <code>free</code> is called multiple times, the subsequent 0N/A * calls to <code>free</code> are treated as a no-op. 0N/A * @throws SQLException if an error occurs releasing 0N/A * the Clob's resources 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 0N/A * Returns a <code>Reader</code> object that contains a partial <code>Clob</code> value, starting 0N/A * with the character specified by pos, which is length characters in length. 0N/A * @param pos the offset to the first character of the partial value to 0N/A * be retrieved. The first character in the Clob is at position 1. 0N/A * @param length the length in characters of the partial value to be retrieved. 0N/A * @return <code>Reader</code> through which the partial <code>Clob</code> value can be read. 0N/A * @throws SQLException if pos is less than 1 or if pos is greater than the number of 0N/A * characters in the <code>Clob</code> or if pos + length is greater than the number of 0N/A * characters in the <code>Clob</code> 0N/A * @exception SQLFeatureNotSupportedException if the JDBC driver does not support