Package org.h2.jdbc

Class JdbcBlob

  • All Implemented Interfaces:
    java.sql.Blob

    public final class JdbcBlob
    extends JdbcLob
    implements java.sql.Blob
    Represents a BLOB value.
    • Constructor Detail

      • JdbcBlob

        public JdbcBlob​(JdbcConnection conn,
                        Value value,
                        JdbcLob.State state,
                        int id)
        INTERNAL
        Parameters:
        conn - it belongs to
        value - of
        state - of the LOB
        id - of the trace object
    • Method Detail

      • length

        public long length()
                    throws java.sql.SQLException
        Returns the length.
        Specified by:
        length in interface java.sql.Blob
        Returns:
        the length
        Throws:
        java.sql.SQLException
      • truncate

        public void truncate​(long len)
                      throws java.sql.SQLException
        [Not supported] Truncates the object.
        Specified by:
        truncate in interface java.sql.Blob
        Parameters:
        len - the new length
        Throws:
        java.sql.SQLException
      • getBytes

        public byte[] getBytes​(long pos,
                               int length)
                        throws java.sql.SQLException
        Returns some bytes of the object.
        Specified by:
        getBytes in interface java.sql.Blob
        Parameters:
        pos - the index, the first byte is at position 1
        length - the number of bytes
        Returns:
        the bytes, at most length bytes
        Throws:
        java.sql.SQLException
      • setBytes

        public int setBytes​(long pos,
                            byte[] bytes)
                     throws java.sql.SQLException
        Fills the Blob. This is only supported for new, empty Blob objects that were created with Connection.createBlob(). The position must be 1, meaning the whole Blob data is set.
        Specified by:
        setBytes in interface java.sql.Blob
        Parameters:
        pos - where to start writing (the first byte is at position 1)
        bytes - the bytes to set
        Returns:
        the length of the added data
        Throws:
        java.sql.SQLException
      • setBytes

        public int setBytes​(long pos,
                            byte[] bytes,
                            int offset,
                            int len)
                     throws java.sql.SQLException
        Sets some bytes of the object.
        Specified by:
        setBytes in interface java.sql.Blob
        Parameters:
        pos - the write position
        bytes - the bytes to set
        offset - the bytes offset
        len - the number of bytes to write
        Returns:
        how many bytes have been written
        Throws:
        java.sql.SQLException
      • getBinaryStream

        public java.io.InputStream getBinaryStream()
                                            throws java.sql.SQLException
        Description copied from class: JdbcLob
        Returns the input stream.
        Specified by:
        getBinaryStream in interface java.sql.Blob
        Overrides:
        getBinaryStream in class JdbcLob
        Returns:
        the input stream
        Throws:
        java.sql.SQLException - on failure
      • setBinaryStream

        public java.io.OutputStream setBinaryStream​(long pos)
                                             throws java.sql.SQLException
        Get a writer to update the Blob. This is only supported for new, empty Blob objects that were created with Connection.createBlob(). The Blob is created in a separate thread, and the object is only updated when OutputStream.close() is called. The position must be 1, meaning the whole Blob data is set.
        Specified by:
        setBinaryStream in interface java.sql.Blob
        Parameters:
        pos - where to start writing (the first byte is at position 1)
        Returns:
        an output stream
        Throws:
        java.sql.SQLException
      • position

        public long position​(byte[] pattern,
                             long start)
                      throws java.sql.SQLException
        [Not supported] Searches a pattern and return the position.
        Specified by:
        position in interface java.sql.Blob
        Parameters:
        pattern - the pattern to search
        start - the index, the first byte is at position 1
        Returns:
        the position (first byte is at position 1), or -1 for not found
        Throws:
        java.sql.SQLException
      • position

        public long position​(java.sql.Blob blobPattern,
                             long start)
                      throws java.sql.SQLException
        [Not supported] Searches a pattern and return the position.
        Specified by:
        position in interface java.sql.Blob
        Parameters:
        blobPattern - the pattern to search
        start - the index, the first byte is at position 1
        Returns:
        the position (first byte is at position 1), or -1 for not found
        Throws:
        java.sql.SQLException
      • getBinaryStream

        public java.io.InputStream getBinaryStream​(long pos,
                                                   long length)
                                            throws java.sql.SQLException
        Returns the input stream, starting from an offset.
        Specified by:
        getBinaryStream in interface java.sql.Blob
        Parameters:
        pos - where to start reading
        length - the number of bytes that will be read
        Returns:
        the input stream to read
        Throws:
        java.sql.SQLException