com.ibm.as400.access

Class AS400JDBCClob

  • java.lang.Object
    • com.ibm.as400.access.AS400JDBCClob
  • All Implemented Interfaces:
    java.io.Serializable, java.sql.Clob
    Direct Known Subclasses:
    AS400JDBCNClob


    public class AS400JDBCClob
    extends java.lang.Object
    implements java.sql.Clob, java.io.Serializable
    The AS400JDBCClob class provides access to character large objects. The data is valid only within the current transaction.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      protected char[] data_ 
      protected int maxLength_ 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void free()
      This method frees the Clob object and releases the resources the resources that it holds.
      java.io.InputStream getAsciiStream()
      Returns the entire CLOB as a stream of ASCII characters.
      java.io.Reader getCharacterStream()
      Returns the entire CLOB as a character stream.
      java.io.Reader getCharacterStream(long pos, long length)
      Returns a Reader object that contains a partial Clob value, starting with the character specified by pos, which is length characters in length.
      java.lang.String getSubString(long position, int length)
      Returns part of the contents of the CLOB.
      long length()
      Returns the length of the CLOB.
      long position(java.sql.Clob pattern, long position)
      Returns the position at which a pattern is found in the CLOB.
      long position(java.lang.String pattern, long position)
      Returns the position at which a pattern is found in the CLOB.
      java.io.OutputStream setAsciiStream(long position)
      Returns a stream that an application can use to write Ascii characters to this CLOB.
      java.io.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, java.lang.String stringToWrite)
      Writes a String to this CLOB, starting at position position.
      int setString(long position, java.lang.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
    • Field Detail

      • data_

        protected char[] data_
      • maxLength_

        protected int maxLength_
    • Method Detail

      • getAsciiStream

        public java.io.InputStream getAsciiStream()
                                           throws java.sql.SQLException
        Returns the entire CLOB as a stream of ASCII characters.
        Specified by:
        getAsciiStream in interface java.sql.Clob
        Returns:
        The stream.
        Throws:
        java.sql.SQLException - If an error occurs.
      • getCharacterStream

        public java.io.Reader getCharacterStream()
                                          throws java.sql.SQLException
        Returns the entire CLOB as a character stream.
        Specified by:
        getCharacterStream in interface java.sql.Clob
        Returns:
        The stream.
        Throws:
        java.sql.SQLException - If an error occurs.
      • getSubString

        public java.lang.String getSubString(long position,
                                    int length)
                                      throws java.sql.SQLException
        Returns part of the contents of the CLOB.
        Specified by:
        getSubString in interface java.sql.Clob
        Parameters:
        position - The start position within the CLOB (1-based).
        length - The length to return.
        Returns:
        The contents.
        Throws:
        java.sql.SQLException - If the start position is not valid, if the length is not valid, or an error occurs.
      • length

        public long length()
                    throws java.sql.SQLException
        Returns the length of the CLOB.
        Specified by:
        length in interface java.sql.Clob
        Returns:
        The length of the CLOB, in characters.
        Throws:
        java.sql.SQLException - If an error occurs.
      • position

        public long position(java.lang.String pattern,
                    long position)
                      throws java.sql.SQLException
        Returns the position at which a pattern is found in the CLOB.
        Specified by:
        position in interface java.sql.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:
        java.sql.SQLException - If the pattern is null, the position is not valid, or an error occurs.
      • position

        public long position(java.sql.Clob pattern,
                    long position)
                      throws java.sql.SQLException
        Returns the position at which a pattern is found in the CLOB.
        Specified by:
        position in interface java.sql.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:
        java.sql.SQLException - If the pattern is null, the position is not valid, or an error occurs.
      • setAsciiStream

        public java.io.OutputStream setAsciiStream(long position)
                                            throws java.sql.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 java.sql.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:
        java.sql.SQLException - If there is an error accessing the CLOB or if the position specified is greater than the length of the CLOB.
      • setCharacterStream

        public java.io.Writer setCharacterStream(long position)
                                          throws java.sql.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 java.sql.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:
        java.sql.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,
                    java.lang.String stringToWrite)
                      throws java.sql.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 java.sql.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:
        java.sql.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,
                    java.lang.String string,
                    int offset,
                    int lengthOfWrite)
                      throws java.sql.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 java.sql.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:
        java.sql.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 java.sql.SQLException
        Truncates this CLOB to a length of lengthOfCLOB characters.
        Specified by:
        truncate in interface java.sql.Clob
        Parameters:
        lengthOfCLOB - The length, in characters, that this CLOB should be after truncation.
        Throws:
        java.sql.SQLException - If there is an error accessing the CLOB or if the length specified is greater than the length of the CLOB.
      • free

        public void free()
                  throws java.sql.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 java.sql.Clob
        Throws:
        java.sql.SQLException - If a database error occurs. if an error occurs releasing the Clob's resources
      • getCharacterStream

        public java.io.Reader getCharacterStream(long pos,
                                        long length)
                                          throws java.sql.SQLException
        Returns a Reader object that contains a partial Clob value, starting with the character specified by pos, which is length characters in length.
        Specified by:
        getCharacterStream in interface java.sql.Clob
        Parameters:
        pos - the offset to the first character of the partial value to be retrieved. The first character in the Clob is at position 1.
        length - the length in characters of the partial value to be retrieved.
        Returns:
        Reader through which the partial Clob value can be read.
        Throws:
        java.sql.SQLException - If a database error occurs. if pos is less than 1 or if pos is greater than the number of characters in the Clob or if pos + length is greater than the number of characters in the Clob