com.ibm.as400.access

Class AS400JDBCClobLocator

  • All Implemented Interfaces:
    Clob
    Direct Known Subclasses:
    AS400JDBCNClobLocator


    public class AS400JDBCClobLocator
    extends Object
    implements Clob
    The AS400JDBCClobLocator class provides access to character large objects. The data is valid only within the current transaction.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      protected com.ibm.as400.access.ConvTable converter_ 
      protected int maxLength_ 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void free()
      This method frees the Clob object and releases 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.
      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.
      int getLocator()
      Get the locator handle corresponding to this ClobLocator
      String getSubString(long position, int length)
      Returns part of the contents of the CLOB.
      long length()
      Returns the length of the current contents of the CLOB in characters.
      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.
    • Field Detail

      • converter_

        protected com.ibm.as400.access.ConvTable converter_
      • maxLength_

        protected int maxLength_

    • Method Detail

      • 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 position within the CLOB (1-based).
        length - The number of characters to return.
        Returns:
        The contents.
        Throws:
        SQLException - If the 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 current contents of the CLOB in characters.
        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. This method is not supported.
        Specified by:
        position in interface Clob
        Parameters:
        pattern - The pattern.
        position - The position within the CLOB to begin searching (1-based).
        Returns:
        The position in the CLOB at which the pattern was found, or -1 if the pattern was 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. This method is not supported.
        Specified by:
        position in interface Clob
        Parameters:
        pattern - The pattern.
        position - The position within the CLOB to begin searching (1-based).
        Returns:
        The position in the CLOB at which the pattern was found, or -1 if the pattern was 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.
      • free

        public void free()
                  throws SQLException
        This method frees the Clob object and releases 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
      • getCharacterStream

        public Reader getCharacterStream(long pos,
                                long length)
                                  throws 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 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:
        SQLException - 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
      • getLocator

        public int getLocator()
                       throws SQLException
        Get the locator handle corresponding to this ClobLocator
        Throws:
        SQLException