com.ibm.as400.access
Class AS400JDBCClob

java.lang.Object
  extended by com.ibm.as400.access.AS400JDBCClob
All Implemented Interfaces:
Clob

public class AS400JDBCClob
extends Object
implements Clob

The AS400JDBCClob class provides access to character large objects. The data is valid only within the current transaction.


Method Summary
Modifier and Type Method and Description
 void free()
          This method frees the Clob object and releases the resources the resources that it holds.
 InputStream getAsciiStream()
          Returns the entire CLOB as a stream of ASCII characters.
 Reader getCharacterStream()
          Returns the entire CLOB as a character stream.
 String getSubString(long position, int length)
          Returns part of the contents of the CLOB.
 long length()
          Returns the length of the CLOB.
 long position(Clob pattern, long position)
          Returns the position at which a pattern is found in the CLOB.
 long position(String pattern, long position)
          Returns the position at which a pattern is found in the CLOB.
 OutputStream setAsciiStream(long position)
          Returns a stream that an application can use to write Ascii characters to this CLOB.
 Writer setCharacterStream(long position)
          Returns a stream that an application can use to write a stream of Unicode characters to this CLOB.
 int setString(long position, String stringToWrite)
          Writes a String to this CLOB, starting at position position.
 int setString(long position, String string, int offset, int lengthOfWrite)
          Writes a String to this CLOB, starting at position position in the CLOB.
 void truncate(long lengthOfCLOB)
          Truncates this CLOB to a length of lengthOfCLOB characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.sql.Clob
getCharacterStream
 

Method Detail

free

public void free()
          throws SQLException
This method frees the Clob object and releases the resources the resources that it holds. The object is invalid once the free method is called. If free is called multiple times, the subsequent calls to free are treated as a no-op.

Specified by:
free in interface Clob
Throws:
SQLException - if an error occurs releasing the Clob's resources

getAsciiStream

public InputStream getAsciiStream()
                           throws SQLException
Returns the entire CLOB as a stream of ASCII characters.

Specified by:
getAsciiStream in interface Clob
Returns:
The stream.
Throws:
SQLException - If an error occurs.

getCharacterStream

public Reader getCharacterStream()
                          throws SQLException
Returns the entire CLOB as a character stream.

Specified by:
getCharacterStream in interface Clob
Returns:
The stream.
Throws:
SQLException - If an error occurs.

getSubString

public String getSubString(long position,
                           int length)
                    throws SQLException
Returns part of the contents of the CLOB.

Specified by:
getSubString in interface Clob
Parameters:
position - The start position within the CLOB (1-based).
length - The length to return.
Returns:
The contents.
Throws:
SQLException - If the start position is not valid, if the length is not valid, or an error occurs.

length

public long length()
            throws SQLException
Returns the length of the CLOB.

Specified by:
length in interface Clob
Returns:
The length of the CLOB, in characters.
Throws:
SQLException - If an error occurs.

position

public long position(String pattern,
                     long position)
              throws SQLException
Returns the position at which a pattern is found in the CLOB.

Specified by:
position in interface Clob
Parameters:
pattern - The pattern.
position - The position within the CLOB to begin searching (1-based).
Returns:
The position at which the pattern is found, or -1 if the pattern is not found.
Throws:
SQLException - If the pattern is null, the position is not valid, or an error occurs.

position

public long position(Clob pattern,
                     long position)
              throws SQLException
Returns the position at which a pattern is found in the CLOB.

Specified by:
position in interface Clob
Parameters:
pattern - The pattern.
position - The position within the CLOB to begin searching (1-based).
Returns:
The position at which the pattern is found, or -1 if the pattern is not found.
Throws:
SQLException - If the pattern is null, the position is not valid, or an error occurs.

setAsciiStream

public OutputStream setAsciiStream(long position)
                            throws SQLException
Returns a stream that an application can use to write Ascii characters to this CLOB. The stream begins at position position, and the CLOB will be truncated after the last character of the write.

Specified by:
setAsciiStream in interface Clob
Parameters:
position - The position (1-based) in the CLOB where writes should start.
Returns:
An OutputStream object to which data can be written by an application.
Throws:
SQLException - If there is an error accessing the CLOB or if the position specified is greater than the length of the CLOB.

setCharacterStream

public Writer setCharacterStream(long position)
                          throws SQLException
Returns a stream that an application can use to write a stream of Unicode characters to this CLOB. The stream begins at position position, and the CLOB will be truncated after the last character of the write.

Specified by:
setCharacterStream in interface Clob
Parameters:
position - The position (1-based) in the CLOB where writes should start.
Returns:
An OutputStream object to which data can be written by an application.
Throws:
SQLException - If there is an error accessing the CLOB or if the position specified is greater than the length of the CLOB.

setString

public int setString(long position,
                     String stringToWrite)
              throws SQLException
Writes a String to this CLOB, starting at position position. The CLOB will be truncated after the last character written.

Specified by:
setString in interface Clob
Parameters:
position - The position (1-based) in the CLOB where writes should start.
stringToWrite - The string that will be written to the CLOB.
Returns:
The number of characters that were written.
Throws:
SQLException - If there is an error accessing the CLOB or if the position specified is greater than the length of the CLOB.

setString

public int setString(long position,
                     String string,
                     int offset,
                     int lengthOfWrite)
              throws SQLException
Writes a String to this CLOB, starting at position position in the CLOB. The CLOB will be truncated after the last character written. The lengthOfWrite characters written will start from offset in the string that was provided by the application.

Specified by:
setString in interface Clob
Parameters:
position - The position (1-based) in the CLOB where writes should start.
string - The string that will be written to the CLOB.
offset - The offset into string to start reading characters (0-based).
lengthOfWrite - The number of characters to write.
Returns:
The number of characters written.
Throws:
SQLException - If there is an error accessing the CLOB value or if the position specified is greater than the length of the CLOB.

truncate

public void truncate(long lengthOfCLOB)
              throws SQLException
Truncates this CLOB to a length of lengthOfCLOB characters.

Specified by:
truncate in interface Clob
Parameters:
lengthOfCLOB - The length, in characters, that this CLOB should be after truncation.
Throws:
SQLException - If there is an error accessing the CLOB or if the length specified is greater than the length of the CLOB.