Java Platform 1.2

java.sql
Interface Clob


public abstract interface Clob

JDBC 2.0 The mapping in the JavaTM programming language for the SQL CLOB type. An SQL CLOB is a built-in type that stores a Character Large Object as a column value in a row of a database table. The driver implements a Clob object using an SQL locator(CLOB), which means that a Clob object contains a logical pointer to the SQL CLOB data rather than the data itself. A Clob object is valid for the duration of the transaction in which it was created.

The Clob interface provides methods for getting the length of an SQL CLOB (Character Large Object) value, for materializing a CLOB value on the client, and for searching for a substring or CLOB object within a CLOB value. Methods in the interfaces ResultSet, CallableStatement, and PreparedStatement, such as getClob and setClob allow a programmer to access the SQL CLOB.


Method Summary
 InputStream getAsciiStream()
          Gets the CLOB value designated by this Clob object as a stream of Ascii bytes.
 Reader getCharacterStream()
          Gets the Clob contents as a Unicode stream.
 String getSubString(long pos, int length)
          Returns a copy of the specified substring in the CLOB value designated by this Clob object.
 long length()
          Returns the number of characters in the CLOB value designated by this Clob object.
 long position(Clob searchstr, long start)
          Determines the character position at which the specified Clob object searchstr appears in this Clob object.
 long position(String searchstr, long start)
          Determines the character position at which the specified substring searchstr appears in the CLOB.
 

Method Detail

length

public long length()
            throws SQLException
Returns the number of characters in the CLOB value designated by this Clob object.
Returns:
length of the CLOB in characters
Throws:
SQLException - if there is an error accessing the length of the CLOB

getSubString

public String getSubString(long pos,
                           int length)
                    throws SQLException
Returns a copy of the specified substring in the CLOB value designated by this Clob object. The substring begins at position pos and has up to length consecutive characters.
Parameters:
pos - the first character of the substring to be extracted. The first character is at position 1.
length - the number of consecutive characters to be copied
Returns:
a String that is the specified substring in the CLOB value designated by this Clob object
Throws:
SQLException - if there is an error accessing the CLOB

getCharacterStream

public Reader getCharacterStream()
                          throws SQLException
Gets the Clob contents as a Unicode stream.
Returns:
a Unicode stream containing the CLOB data
Throws:
SQLException - if there is an error accessing the CLOB

getAsciiStream

public InputStream getAsciiStream()
                           throws SQLException
Gets the CLOB value designated by this Clob object as a stream of Ascii bytes.
Returns:
an ascii stream containing the CLOB data
Throws:
SQLException - if there is an error accessing the CLOB value

position

public long position(String searchstr,
                     long start)
              throws SQLException
Determines the character position at which the specified substring searchstr appears in the CLOB. The search begins at position start.
Parameters:
searchstr - the substring for which to search
start - the position at which to begin searching; the first position is 1
Returns:
the position at which the substring appears, else -1; the first position is 1
Throws:
SQLException - if there is an error accessing the CLOB value

position

public long position(Clob searchstr,
                     long start)
              throws SQLException
Determines the character position at which the specified Clob object searchstr appears in this Clob object. The search begins at position start.
Parameters:
searchstr - the Clob object for which to search
start - the position at which to begin searching; the first position is 1
Returns:
the position at which the Clob object appears, else -1; the first position is 1
Throws:
SQLException - if there is an error accessing the CLOB value

Java Platform 1.2

Submit a bug or feature Version 1.2 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.