com.informix.jdbc

Class IfxCblob

  • java.lang.Object
    • com.informix.jdbc.IfxCblob
  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.sql.Clob, java.sql.NClob


    public class IfxCblob
    extends java.lang.Object
    implements java.sql.NClob, java.sql.Clob

    By default, a CLOB is a transaction duration reference to a character large object.

    • Constructor Summary

      Constructors 
      Modifier Constructor and Description
        IfxCblob()
      Creates an IfxCblob instance.
      protected IfxCblob(byte[] buffer)
      Creates an IfxCblob instance with the given byte[].
        IfxCblob(java.sql.Connection c, byte[] buffer)
      Creates an IfxCblob instance with the given connection and a buffer containing data.
        IfxCblob(java.sql.Connection connection, IfxLocator locator)
      Creates an IfxCblob instance with a given connection and a locator.
        IfxCblob(java.sql.Connection connection, IfxLocator locator, int mode) 
        IfxCblob(java.sql.Connection conn, java.io.InputStream fin, int length)
      Creates an IfxCblob instance with a given connection, an inputStream and number of bytes to write.
        IfxCblob(java.sql.Connection conn, java.io.InputStream fin, int length, IfxLobDescriptor loDesc)
      Creates an IfxCblob instance with a given connection, an inputStream, number of bytes to write and a specified lob descriptor.
        IfxCblob(java.sql.Connection conn, java.io.InputStream fin, int length, java.lang.String sbspaceName)
      Creates an IfxCblob instance with a given connection, an inputStream and number of bytes to write to a specified smart blob space.
        IfxCblob(java.sql.Connection conn, java.lang.String str)
      Creates an IfxCblob instance with a given connection and a string of data.
        IfxCblob(java.sql.Connection conn, java.lang.String str, IfxLobDescriptor loDesc)
      Creates an IfxCblob instance with a given connection and a string of data and a specified lob descriptor.
        IfxCblob(java.sql.Connection conn, java.lang.String str, java.lang.String sbspaceName)
      Creates an IfxCblob instance with a given connection and a string of data and a specified smart blob space.
        IfxCblob(com.informix.jdbc.IfxConnection con) 
        IfxCblob(com.informix.jdbc.IfxConnection connection, IfxLocator locator, int mode)
      Creates an IfxCblob instance with a given connection and a locator.
        IfxCblob(IfxLocator locator)
      Creates an IfxCblob instance with the given locator.
      protected IfxCblob(com.informix.jdbc.IfxTmpFile tempFile) 
        IfxCblob(java.io.InputStream fin)
      Creates an IfxCblob instance with the given input stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      protected void checkIfFreed() 
      void close() 
      com.informix.jdbc.IfxLob disableFinalize(boolean arg0) 
      void free() 
      protected byte[] getAll() 
      java.io.InputStream getAsciiStream()
      Gets the smart large object contents as an ASCII stream.
      java.io.InputStream getBinaryStream(long arg0, long arg1) 
      protected byte[] getBytes() 
      java.io.Reader getCharacterStream()
      Gets the smart large object contents as a Unicode stream.
      java.io.Reader getCharacterStream(long pos, long length) 
      protected short getIfxLobType() 
      IfxLocator getLocator() 
      IfxLoStat getLoStat() 
      protected byte[] getPortion(long arg0, long arg1) 
      protected byte[] getPortion(long arg0, long arg1, long arg2) 
      protected java.io.InputStream getStream() 
      protected java.io.InputStream getStream(long arg0, long arg1) 
      protected java.io.InputStream getStreamImd() 
      java.lang.String getSubString(long position, int length) 
      long length() 
      protected void loadSmBlob() 
      long position(java.sql.Clob searchstr, long start)
      Determines the character position at which the given substring occurs.
      long position(java.lang.String searchstr, long start)
      Determines the character position at which the given substring occurs.
      long seek(long arg0, int arg1) 
      java.io.OutputStream setAsciiStream(long pos)
      Retrieves a stream to be used to write Ascii characters to the CLOB value that this Clob object represents, starting at position pos.
      void setAsciiStream(long position, java.io.InputStream fin, int length)
      Writes ascii stream of data from an InputStream to an already existing smart large blob object.
      protected int setBuffer(byte[] arg0) 
      protected int setBuffer(byte[] arg0, int arg1, int arg2) 
      java.io.Writer setCharacterStream(long pos)
      Retrieves a stream to be used to write a stream of Unicode characters to the CLOB value that this Clob object represents, at position pos.
      protected void setConnection(com.informix.jdbc.IfxConnection arg0) 
      protected void setIfxLobType(short arg0) 
      protected void setLoadFlag() 
      protected void setLocator(IfxLocator arg0) 
      protected void setMode(int arg0) 
      protected void setSize(long arg0) 
      protected void setStream(java.io.InputStream arg0, int arg1) 
      int setString(long pos, java.lang.String str)
      Writes the given Java String to the CLOB value that this Clob object designates at the position pos.
      int setString(long pos, java.lang.String str, int offset, int len)
      Writes len characters of str, starting at character offset, to the CLOB value that this Clob represents.
      void truncate(long arg0) 
      void upgradeToWriteLock() 
      protected void verifySmbMode() 
      protected void verifySmbMode(boolean arg0) 
      long where() 
      • 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

        truncate
    • Field Detail

      • locatorPointer

        protected IfxLocator locatorPointer
      • conn

        protected com.informix.jdbc.IfxConnection conn
      • isBlob_loaded

        protected boolean isBlob_loaded
      • tempBlobFile

        protected com.informix.jdbc.IfxTmpFile tempBlobFile
      • blobStream

        protected java.io.InputStream blobStream
      • blobBuffer

        protected byte[] blobBuffer
      • BlobFileName

        protected java.lang.String BlobFileName
      • blobSize

        protected long blobSize
      • ifxType

        protected short ifxType
      • smartBlobMode

        protected int smartBlobMode
    • Constructor Detail

      • IfxCblob

        public IfxCblob()
        Creates an IfxCblob instance. An IfxCblob object created using this constructor cannot be used for accessing the Clob.
      • IfxCblob

        public IfxCblob(IfxLocator locator)
        Creates an IfxCblob instance with the given locator. An IfxCblob object created using this constructor cannot be used for accessing the Clob.
        Parameters:
        locator - The locator that references the smart large object
      • IfxCblob

        public IfxCblob(com.informix.jdbc.IfxConnection con)
                 throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • IfxCblob

        public IfxCblob(com.informix.jdbc.IfxConnection connection,
                        IfxLocator locator,
                        int mode)
                 throws java.sql.SQLException
        Creates an IfxCblob instance with a given connection and a locator. The object will be opened in the database using the given mode.
        Parameters:
        connection - The IfxConnection object
        locator - The locator that references the smart large object
        mode - Mode from com.informix.jdbc.IfxLob
        Throws:
        java.sql.SQLException - if there is a database access error
      • IfxCblob

        public IfxCblob(java.sql.Connection connection,
                        IfxLocator locator)
                 throws java.sql.SQLException
        Creates an IfxCblob instance with a given connection and a locator. The object will be opened in the database in NODIRTY_READ mode.
        Parameters:
        connection - The IfxConnection object
        locator - The locator that references the smart large object
        Throws:
        java.sql.SQLException - if there is a database access error
      • IfxCblob

        public IfxCblob(java.sql.Connection connection,
                        IfxLocator locator,
                        int mode)
                 throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • IfxCblob

        protected IfxCblob(byte[] buffer)
        Creates an IfxCblob instance with the given byte[].
        Parameters:
        buffer - The data buffer
      • IfxCblob

        public IfxCblob(java.sql.Connection c,
                        byte[] buffer)
                 throws java.sql.SQLException
        Creates an IfxCblob instance with the given connection and a buffer containing data.
        Parameters:
        c - the Connection object
        buffer - the data buffer
        Throws:
        java.sql.SQLException - if object instance cannot be instantiated
      • IfxCblob

        public IfxCblob(java.io.InputStream fin)
        Creates an IfxCblob instance with the given input stream. An IfxCblob object created using this constructor cannot be used for accessing the Clob.
        Parameters:
        fin - The input stream for this smart large object
      • IfxCblob

        protected IfxCblob(com.informix.jdbc.IfxTmpFile tempFile)
      • IfxCblob

        public IfxCblob(java.sql.Connection conn,
                        java.io.InputStream fin,
                        int length)
                 throws java.sql.SQLException
        Creates an IfxCblob instance with a given connection, an inputStream and number of bytes to write.
        Parameters:
        conn - The IfxConnection object.
        fin - The input stream from which the data will be written into the smart large object.
        length - Number of bytes to be written.
        Throws:
        java.sql.SQLException - if object instance cannot be instantiated.
      • IfxCblob

        public IfxCblob(java.sql.Connection conn,
                        java.io.InputStream fin,
                        int length,
                        java.lang.String sbspaceName)
                 throws java.sql.SQLException
        Creates an IfxCblob instance with a given connection, an inputStream and number of bytes to write to a specified smart blob space.
        Parameters:
        conn - The IfxConnection object.
        fin - The input stream from which the data will be written into the smart large object.
        length - Number of bytes to be written.
        sbspaceName - specified smart blob space name.
        Throws:
        java.sql.SQLException - if object instance cannot be instantiated.
      • IfxCblob

        public IfxCblob(java.sql.Connection conn,
                        java.io.InputStream fin,
                        int length,
                        IfxLobDescriptor loDesc)
                 throws java.sql.SQLException
        Creates an IfxCblob instance with a given connection, an inputStream, number of bytes to write and a specified lob descriptor.
        Parameters:
        conn - The IfxConnection object.
        fin - The input stream from which the data will be written into the smart large object.
        length - Number of bytes to be written.
        loDesc - user created lob descriptor.
        Throws:
        java.sql.SQLException - if object instance cannot be instantiated.
      • IfxCblob

        public IfxCblob(java.sql.Connection conn,
                        java.lang.String str)
                 throws java.sql.SQLException
        Creates an IfxCblob instance with a given connection and a string of data.
        Parameters:
        conn - The IfxConnection object.
        str - The String from which the data will be written to smart blob.
        Throws:
        java.sql.SQLException - if object instance cannot be instantiated.
      • IfxCblob

        public IfxCblob(java.sql.Connection conn,
                        java.lang.String str,
                        java.lang.String sbspaceName)
                 throws java.sql.SQLException
        Creates an IfxCblob instance with a given connection and a string of data and a specified smart blob space.
        Parameters:
        conn - The IfxConnection object.
        str - The String from which the data will be written to smart blob.
        sbspaceName - specified smart blob space name.
        Throws:
        java.sql.SQLException - if object instance cannot be instantiated.
      • IfxCblob

        public IfxCblob(java.sql.Connection conn,
                        java.lang.String str,
                        IfxLobDescriptor loDesc)
                 throws java.sql.SQLException
        Creates an IfxCblob instance with a given connection and a string of data and a specified lob descriptor.
        Parameters:
        conn - The IfxConnection object.
        str - The string from which the data will be written to smart blob.
        loDesc - user defined lob descriptor.
        Throws:
        java.sql.SQLException - if object instance cannot be instantiated.
    • Method Detail

      • length

        public long length()
                    throws java.sql.SQLException
        Specified by:
        length in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • getSubString

        public java.lang.String getSubString(long position,
                                             int length)
                                      throws java.sql.SQLException
        Specified by:
        getSubString in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • getCharacterStream

        public java.io.Reader getCharacterStream()
                                          throws java.sql.SQLException
        Gets the smart large object contents as a Unicode stream. Characters are converted from database encoding to unicode.
        Specified by:
        getCharacterStream in interface java.sql.Clob
        Returns:
        A Unicode stream containing the smart large object data.
        Throws:
        java.sql.SQLException
      • getCharacterStream

        public java.io.Reader getCharacterStream(long pos,
                                                 long length)
                                          throws java.sql.SQLException
        Specified by:
        getCharacterStream in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • getAsciiStream

        public java.io.InputStream getAsciiStream()
                                           throws java.sql.SQLException
        Gets the smart large object contents as an ASCII stream. This method can be used to fetch data from a blob. If the IfxCblob object is created with following constructors; IfxCblob() or IfxCblob(IfxLocaor locator) or IfxCblob(InputStream fin) this method cannot be used. This method can be used when an IfxCblob object gets created out of a resultSet.getBlob() statement or using the following constructors; IfxCblob(IfxConnection connection, IfxLocator locator) IfxCblob(IfxConnection conn, InputStream fin, int length) IfxCblob(IfxConnection conn, InputStream fin, int length, String sbspaceName) IfxCblob(IfxConnection conn, InputStream fin, int length, IfxLobDescriptor loDesc) IfxCblob(IfxConnection conn, String str) IfxCblob(IfxConnection conn, String str, String sbspaceName) IfxCblob(IfxConnection conn, String str, IfxLobDescriptor loDesc)
        Specified by:
        getAsciiStream in interface java.sql.Clob
        Returns:
        An ASCII stream containing the smart large object data.
        Throws:
        java.sql.SQLException - if there is a problem getting the stream.
      • position

        public long position(java.lang.String searchstr,
                             long start)
                      throws java.sql.SQLException
        Determines the character position at which the given substring occurs. This method can be used to find a match for a pattern within a clob. In case IfxCblob object is created with following constructors; IfxCblob() or IfxCblob(IfxLocaor locator) or IfxCblob(InputStream fin) this method cannot be used. This method can be used when an IfxCblob object gets created out of a resultSet.getBlob() statement or using the following constructors; IfxCblob(IfxConnection connection, IfxLocator locator) IfxCblob(IfxConnection conn, InputStream fin, int length) IfxCblob(IfxConnection conn, InputStream fin, int length, String sbspaceName) IfxCblob(IfxConnection conn, InputStream fin, int length, IfxLobDescriptor loDesc) IfxCblob(IfxConnection conn, String str) IfxCblob(IfxConnection conn, String str, String sbspaceName) IfxCblob(IfxConnection conn, String str, IfxLobDescriptor loDesc)
        Specified by:
        position in interface java.sql.Clob
        Parameters:
        searchstr - The substring for which you want to search.
        start - The position at which searching begins.
        Returns:
        The position at which the substring appears, or -1 if the string does not appear in the smart large object.
        Throws:
        java.sql.SQLException - if the string cannot be read or the the index is out of bounds.
      • position

        public long position(java.sql.Clob searchstr,
                             long start)
                      throws java.sql.SQLException
        Determines the character position at which the given substring occurs. This method can be used to find a match for a pattern within a clob. If the IfxCblob object is created with the following constructors; IfxCblob() or IfxCblob(IfxLocaor locator) or IfxCblob(InputStream fin) this method cannot be used. This method can be used when an IfxCblob object gets created out of a resultSet.getBlob() statement or using the following constructors; IfxCblob(IfxConnection connection, IfxLocator locator) IfxCblob(IfxConnection conn, InputStream fin, int length) IfxCblob(IfxConnection conn, InputStream fin, int length, String sbspaceName) IfxCblob(IfxConnection conn, InputStream fin, int length, IfxLobDescriptor loDesc) IfxCblob(IfxConnection conn, String str) IfxCblob(IfxConnection conn, String str, String sbspaceName) IfxCblob(IfxConnection conn, String str, IfxLobDescriptor loDesc)
        Specified by:
        position in interface java.sql.Clob
        Parameters:
        searchstr - The substring for which you want to search.
        start - The position at which searching begins.
        Returns:
        The position at which the substring appears, or -1 if the string does not appear in the smart large object.
        Throws:
        java.sql.SQLException - if there is an error accessing the CLOB
      • setAsciiStream

        public void setAsciiStream(long position,
                                   java.io.InputStream fin,
                                   int length)
                            throws java.sql.SQLException
        Writes ascii stream of data from an InputStream to an already existing smart large blob object. Characters are written without any codeset conversion This method can be used to fetch data from a blob. If the IfxCblob object is created with following constructors; IfxCblob() or IfxCblob(IfxLocaor locator) or IfxCblob(InputStream fin) this method cannot be used. This method can be used when an IfxCblob object gets created out of a resultSet.getBlob() statement or using the following constructors; IfxCblob(IfxConnection connection, IfxLocator locator) IfxCblob(IfxConnection conn, InputStream fin, int length) IfxCblob(IfxConnection conn, InputStream fin, int length, String sbspaceName) IfxCblob(IfxConnection conn, InputStream fin, int length, IfxLobDescriptor loDesc) IfxCblob(IfxConnection conn, String str) IfxCblob(IfxConnection conn, String str, String sbspaceName) IfxCblob(IfxConnection conn, String str, IfxLobDescriptor loDesc)
        Parameters:
        position - Position at which smart large object will be written.
        fin - InputStream
        length - Number of bytes to be written from the input stream.
        Throws:
        java.sql.SQLException - if the type is not a CLOB, the large object is invalid or the large object cannot be opened.
      • setString

        public int setString(long pos,
                             java.lang.String str)
                      throws java.sql.SQLException
        Writes the given Java String to the CLOB value that this Clob object designates at the position pos. The Unicode string is always conveted to database codeset before writing to clob.
        Specified by:
        setString in interface java.sql.Clob
        Parameters:
        str - the string to be written to the CLOB value that this Clob designates
        Returns:
        the number of characters written
        Throws:
        java.sql.SQLException - if there is an error accessing the CLOB value
      • setString

        public int setString(long pos,
                             java.lang.String str,
                             int offset,
                             int len)
                      throws java.sql.SQLException
        Writes len characters of str, starting at character offset, to the CLOB value that this Clob represents. The characters are always conveted to database locale codeset before writing to clob. In case IfxClob object is created with following constructors, IfxCblob() or IfxCblob(IfxLocaor locator) or IfxCblob(InputStream fin) this method cannot be used. The Unicode characters are always conveted to database codeset before writing to clob.
        Specified by:
        setString in interface java.sql.Clob
        Parameters:
        pos - the position at which to start writing to this CLOB object
        str - the string to be written to the CLOB value that this Clob object represents
        offset - the offset into str to start reading the characters to be written
        len - the number of characters to be written
        Returns:
        the number of characters written
        Throws:
        java.sql.SQLException - if there is an error accessing smart large object
      • setAsciiStream

        public java.io.OutputStream setAsciiStream(long pos)
                                            throws java.sql.SQLException
        Retrieves a stream to be used to write Ascii characters to the CLOB value that this Clob object represents, starting at position pos. Characters are written without any codeset conversion In case IfxClob object is created with following constructors, IfxCblob() or IfxCblob(IfxLocaor locator) or IfxCblob(InputStream fin) this method cannot be used.
        Specified by:
        setAsciiStream in interface java.sql.Clob
        Parameters:
        pos - the position at which to start writing to this CLOB object
        Returns:
        the stream to which ASCII encoded characters can be written
        Throws:
        java.sql.SQLException - if there is an error accessing the CLOB value
      • setCharacterStream

        public java.io.Writer setCharacterStream(long pos)
                                          throws java.sql.SQLException
        Retrieves a stream to be used to write a stream of Unicode characters to the CLOB value that this Clob object represents, at position pos. The Unicode characters are always conveted to database codeset before writing to clob. In case IfxClob object is created with following constructors, IfxCblob() or IfxCblob(IfxLocaor locator) or IfxCblob(InputStream fin) this method cannot be used.
        Specified by:
        setCharacterStream in interface java.sql.Clob
        Parameters:
        pos - the position at which to start writing to the CLOB value
        Returns:
        a stream to which Unicode encoded characters can be written
        Throws:
        java.sql.SQLException - if there is an error accessing the CLOB value
      • free

        public void free()
                  throws java.sql.SQLException
        Specified by:
        free in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • getLocator

        public IfxLocator getLocator()
                              throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setLocator

        protected void setLocator(IfxLocator arg0)
                           throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setIfxLobType

        protected void setIfxLobType(short arg0)
      • setSize

        protected void setSize(long arg0)
      • setConnection

        protected void setConnection(com.informix.jdbc.IfxConnection arg0)
      • setLoadFlag

        protected void setLoadFlag()
      • getIfxLobType

        protected short getIfxLobType()
      • setMode

        protected void setMode(int arg0)
      • getBytes

        protected byte[] getBytes()
                           throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getPortion

        protected byte[] getPortion(long arg0,
                                    long arg1)
                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getAll

        protected byte[] getAll()
                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getPortion

        protected byte[] getPortion(long arg0,
                                    long arg1,
                                    long arg2)
                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getStreamImd

        protected java.io.InputStream getStreamImd()
                                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getStream

        protected java.io.InputStream getStream()
                                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getStream

        protected java.io.InputStream getStream(long arg0,
                                                long arg1)
                                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getBinaryStream

        public java.io.InputStream getBinaryStream(long arg0,
                                                   long arg1)
                                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setStream

        protected void setStream(java.io.InputStream arg0,
                                 int arg1)
                          throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setBuffer

        protected int setBuffer(byte[] arg0)
                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setBuffer

        protected int setBuffer(byte[] arg0,
                                int arg1,
                                int arg2)
                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • seek

        public long seek(long arg0,
                         int arg1)
                  throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • where

        public long where()
                   throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getLoStat

        public IfxLoStat getLoStat()
                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • truncate

        public void truncate(long arg0)
                      throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • close

        public void close()
                   throws java.sql.SQLException
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.sql.SQLException
      • loadSmBlob

        protected void loadSmBlob()
                           throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • verifySmbMode

        protected void verifySmbMode()
                              throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • verifySmbMode

        protected void verifySmbMode(boolean arg0)
                              throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • checkIfFreed

        protected void checkIfFreed()
                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • upgradeToWriteLock

        public void upgradeToWriteLock()
                                throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • disableFinalize

        public com.informix.jdbc.IfxLob disableFinalize(boolean arg0)