Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/sql/Clob.java
38829 views
/*1* Copyright (c) 1998, 2013, 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;2627import java.io.Reader;2829/**30* The mapping in the Java™ programming language31* for the SQL <code>CLOB</code> type.32* An SQL <code>CLOB</code> is a built-in type33* that stores a Character Large Object as a column value in a row of34* a database table.35* By default drivers implement a <code>Clob</code> object using an SQL36* <code>locator(CLOB)</code>, which means that a <code>Clob</code> object37* contains a logical pointer to the SQL <code>CLOB</code> data rather than38* the data itself. A <code>Clob</code> object is valid for the duration39* of the transaction in which it was created.40* <P>The <code>Clob</code> interface provides methods for getting the41* length of an SQL <code>CLOB</code> (Character Large Object) value,42* for materializing a <code>CLOB</code> value on the client, and for43* searching for a substring or <code>CLOB</code> object within a44* <code>CLOB</code> value.45* Methods in the interfaces {@link ResultSet},46* {@link CallableStatement}, and {@link PreparedStatement}, such as47* <code>getClob</code> and <code>setClob</code> allow a programmer to48* access an SQL <code>CLOB</code> value. In addition, this interface49* has methods for updating a <code>CLOB</code> value.50* <p>51* All methods on the <code>Clob</code> interface must be fully implemented if the52* JDBC driver supports the data type.53*54* @since 1.255*/5657public interface Clob {5859/**60* Retrieves the number of characters61* in the <code>CLOB</code> value62* designated by this <code>Clob</code> object.63*64* @return length of the <code>CLOB</code> in characters65* @exception SQLException if there is an error accessing the66* length of the <code>CLOB</code> value67* @exception SQLFeatureNotSupportedException if the JDBC driver does not support68* this method69* @since 1.270*/71long length() throws SQLException;7273/**74* Retrieves a copy of the specified substring75* in the <code>CLOB</code> value76* designated by this <code>Clob</code> object.77* The substring begins at position78* <code>pos</code> and has up to <code>length</code> consecutive79* characters.80*81* @param pos the first character of the substring to be extracted.82* The first character is at position 1.83* @param length the number of consecutive characters to be copied;84* the value for length must be 0 or greater85* @return a <code>String</code> that is the specified substring in86* the <code>CLOB</code> value designated by this <code>Clob</code> object87* @exception SQLException if there is an error accessing the88* <code>CLOB</code> value; if pos is less than 1 or length is89* less than 090* @exception SQLFeatureNotSupportedException if the JDBC driver does not support91* this method92* @since 1.293*/94String getSubString(long pos, int length) throws SQLException;9596/**97* Retrieves the <code>CLOB</code> value designated by this <code>Clob</code>98* object as a <code>java.io.Reader</code> object (or as a stream of99* characters).100*101* @return a <code>java.io.Reader</code> object containing the102* <code>CLOB</code> data103* @exception SQLException if there is an error accessing the104* <code>CLOB</code> value105* @exception SQLFeatureNotSupportedException if the JDBC driver does not support106* this method107* @see #setCharacterStream108* @since 1.2109*/110java.io.Reader getCharacterStream() throws SQLException;111112/**113* Retrieves the <code>CLOB</code> value designated by this <code>Clob</code>114* object as an ascii stream.115*116* @return a <code>java.io.InputStream</code> object containing the117* <code>CLOB</code> data118* @exception SQLException if there is an error accessing the119* <code>CLOB</code> value120* @exception SQLFeatureNotSupportedException if the JDBC driver does not support121* this method122* @see #setAsciiStream123* @since 1.2124*/125java.io.InputStream getAsciiStream() throws SQLException;126127/**128* Retrieves the character position at which the specified substring129* <code>searchstr</code> appears in the SQL <code>CLOB</code> value130* represented by this <code>Clob</code> object. The search131* begins at position <code>start</code>.132*133* @param searchstr the substring for which to search134* @param start the position at which to begin searching; the first position135* is 1136* @return the position at which the substring appears or -1 if it is not137* present; the first position is 1138* @exception SQLException if there is an error accessing the139* <code>CLOB</code> value or if pos is less than 1140* @exception SQLFeatureNotSupportedException if the JDBC driver does not support141* this method142* @since 1.2143*/144long position(String searchstr, long start) throws SQLException;145146/**147* Retrieves the character position at which the specified148* <code>Clob</code> object <code>searchstr</code> appears in this149* <code>Clob</code> object. The search begins at position150* <code>start</code>.151*152* @param searchstr the <code>Clob</code> object for which to search153* @param start the position at which to begin searching; the first154* position is 1155* @return the position at which the <code>Clob</code> object appears156* or -1 if it is not present; the first position is 1157* @exception SQLException if there is an error accessing the158* <code>CLOB</code> value or if start is less than 1159* @exception SQLFeatureNotSupportedException if the JDBC driver does not support160* this method161* @since 1.2162*/163long position(Clob searchstr, long start) throws SQLException;164165//---------------------------- jdbc 3.0 -----------------------------------166167/**168* Writes the given Java <code>String</code> to the <code>CLOB</code>169* value that this <code>Clob</code> object designates at the position170* <code>pos</code>. The string will overwrite the existing characters171* in the <code>Clob</code> object starting at the position172* <code>pos</code>. If the end of the <code>Clob</code> value is reached173* while writing the given string, then the length of the <code>Clob</code>174* value will be increased to accommodate the extra characters.175* <p>176* <b>Note:</b> If the value specified for <code>pos</code>177* is greater then the length+1 of the <code>CLOB</code> value then the178* behavior is undefined. Some JDBC drivers may throw a179* <code>SQLException</code> while other drivers may support this180* operation.181*182* @param pos the position at which to start writing to the <code>CLOB</code>183* value that this <code>Clob</code> object represents;184* The first position is 1185* @param str the string to be written to the <code>CLOB</code>186* value that this <code>Clob</code> designates187* @return the number of characters written188* @exception SQLException if there is an error accessing the189* <code>CLOB</code> value or if pos is less than 1190*191* @exception SQLFeatureNotSupportedException if the JDBC driver does not support192* this method193* @since 1.4194*/195int setString(long pos, String str) throws SQLException;196197/**198* Writes <code>len</code> characters of <code>str</code>, starting199* at character <code>offset</code>, to the <code>CLOB</code> value200* that this <code>Clob</code> represents. The string will overwrite the existing characters201* in the <code>Clob</code> object starting at the position202* <code>pos</code>. If the end of the <code>Clob</code> value is reached203* while writing the given string, then the length of the <code>Clob</code>204* value will be increased to accommodate the extra characters.205* <p>206* <b>Note:</b> If the value specified for <code>pos</code>207* is greater then the length+1 of the <code>CLOB</code> value then the208* behavior is undefined. Some JDBC drivers may throw a209* <code>SQLException</code> while other drivers may support this210* operation.211*212* @param pos the position at which to start writing to this213* <code>CLOB</code> object; The first position is 1214* @param str the string to be written to the <code>CLOB</code>215* value that this <code>Clob</code> object represents216* @param offset the offset into <code>str</code> to start reading217* the characters to be written218* @param len the number of characters to be written219* @return the number of characters written220* @exception SQLException if there is an error accessing the221* <code>CLOB</code> value or if pos is less than 1222*223* @exception SQLFeatureNotSupportedException if the JDBC driver does not support224* this method225* @since 1.4226*/227int setString(long pos, String str, int offset, int len) throws SQLException;228229/**230* Retrieves a stream to be used to write Ascii characters to the231* <code>CLOB</code> value that this <code>Clob</code> object represents,232* starting at position <code>pos</code>. Characters written to the stream233* will overwrite the existing characters234* in the <code>Clob</code> object starting at the position235* <code>pos</code>. If the end of the <code>Clob</code> value is reached236* while writing characters to the stream, then the length of the <code>Clob</code>237* value will be increased to accommodate the extra characters.238* <p>239* <b>Note:</b> If the value specified for <code>pos</code>240* is greater then the length+1 of the <code>CLOB</code> value then the241* behavior is undefined. Some JDBC drivers may throw a242* <code>SQLException</code> while other drivers may support this243* operation.244*245* @param pos the position at which to start writing to this246* <code>CLOB</code> object; The first position is 1247* @return the stream to which ASCII encoded characters can be written248* @exception SQLException if there is an error accessing the249* <code>CLOB</code> value or if pos is less than 1250* @exception SQLFeatureNotSupportedException if the JDBC driver does not support251* this method252* @see #getAsciiStream253*254* @since 1.4255*/256java.io.OutputStream setAsciiStream(long pos) throws SQLException;257258/**259* Retrieves a stream to be used to write a stream of Unicode characters260* to the <code>CLOB</code> value that this <code>Clob</code> object261* represents, at position <code>pos</code>. Characters written to the stream262* will overwrite the existing characters263* in the <code>Clob</code> object starting at the position264* <code>pos</code>. If the end of the <code>Clob</code> value is reached265* while writing characters to the stream, then the length of the <code>Clob</code>266* value will be increased to accommodate the extra characters.267* <p>268* <b>Note:</b> If the value specified for <code>pos</code>269* is greater then the length+1 of the <code>CLOB</code> value then the270* behavior is undefined. Some JDBC drivers may throw a271* <code>SQLException</code> while other drivers may support this272* operation.273*274* @param pos the position at which to start writing to the275* <code>CLOB</code> value; The first position is 1276*277* @return a stream to which Unicode encoded characters can be written278* @exception SQLException if there is an error accessing the279* <code>CLOB</code> value or if pos is less than 1280* @exception SQLFeatureNotSupportedException if the JDBC driver does not support281* this method282* @see #getCharacterStream283*284* @since 1.4285*/286java.io.Writer setCharacterStream(long pos) throws SQLException;287288/**289* Truncates the <code>CLOB</code> value that this <code>Clob</code>290* designates to have a length of <code>len</code>291* characters.292* <p>293* <b>Note:</b> If the value specified for <code>pos</code>294* is greater then the length+1 of the <code>CLOB</code> value then the295* behavior is undefined. Some JDBC drivers may throw a296* <code>SQLException</code> while other drivers may support this297* operation.298*299* @param len the length, in characters, to which the <code>CLOB</code> value300* should be truncated301* @exception SQLException if there is an error accessing the302* <code>CLOB</code> value or if len is less than 0303*304* @exception SQLFeatureNotSupportedException if the JDBC driver does not support305* this method306* @since 1.4307*/308void truncate(long len) throws SQLException;309310/**311* This method frees the <code>Clob</code> object and releases the resources the resources312* that it holds. The object is invalid once the <code>free</code> method313* is called.314* <p>315* After <code>free</code> has been called, any attempt to invoke a316* method other than <code>free</code> will result in a <code>SQLException</code>317* being thrown. If <code>free</code> is called multiple times, the subsequent318* calls to <code>free</code> are treated as a no-op.319* <p>320* @throws SQLException if an error occurs releasing321* the Clob's resources322*323* @exception SQLFeatureNotSupportedException if the JDBC driver does not support324* this method325* @since 1.6326*/327void free() throws SQLException;328329/**330* Returns a <code>Reader</code> object that contains a partial <code>Clob</code> value, starting331* with the character specified by pos, which is length characters in length.332*333* @param pos the offset to the first character of the partial value to334* be retrieved. The first character in the Clob is at position 1.335* @param length the length in characters of the partial value to be retrieved.336* @return <code>Reader</code> through which the partial <code>Clob</code> value can be read.337* @throws SQLException if pos is less than 1 or if pos is greater than the number of338* characters in the <code>Clob</code> or if pos + length is greater than the number of339* characters in the <code>Clob</code>340*341* @exception SQLFeatureNotSupportedException if the JDBC driver does not support342* this method343* @since 1.6344*/345Reader getCharacterStream(long pos, long length) throws SQLException;346347}348349350