Package org.h2.jdbc

Class JdbcBlob

java.lang.Object
org.h2.message.TraceObject
org.h2.jdbc.JdbcLob
org.h2.jdbc.JdbcBlob
All Implemented Interfaces:
Blob

public final class JdbcBlob extends JdbcLob implements Blob
Represents a BLOB value.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.h2.jdbc.JdbcLob

    JdbcLob.State
  • Field Summary

    Fields inherited from class org.h2.message.TraceObject

    ARRAY, BLOB, CALLABLE_STATEMENT, CLOB, CONNECTION, DATA_SOURCE, DATABASE_META_DATA, PARAMETER_META_DATA, PREPARED_STATEMENT, RESULT_SET, RESULT_SET_META_DATA, SAVEPOINT, SQLXML, STATEMENT, trace, XA_DATA_SOURCE, XID
  • Constructor Summary

    Constructors
    Constructor
    Description
    JdbcBlob(JdbcConnection conn, org.h2.value.Value value, JdbcLob.State state, int id)
    INTERNAL
  • Method Summary

    Modifier and Type
    Method
    Description
     
    getBinaryStream(long pos, long length)
    Returns the input stream, starting from an offset.
    byte[]
    getBytes(long pos, int length)
    Returns some bytes of the object.
    long
    Returns the length.
    long
    position(byte[] pattern, long start)
    [Not supported] Searches a pattern and return the position.
    long
    position(Blob blobPattern, long start)
    [Not supported] Searches a pattern and return the position.
    setBinaryStream(long pos)
    Get a writer to update the Blob.
    int
    setBytes(long pos, byte[] bytes)
    Fills the Blob.
    int
    setBytes(long pos, byte[] bytes, int offset, int len)
    Sets some bytes of the object.
    void
    truncate(long len)
    [Not supported] Truncates the object.

    Methods inherited from class org.h2.jdbc.JdbcLob

    free, toString

    Methods inherited from class org.h2.message.TraceObject

    debugCode, debugCodeAssign, debugCodeCall, debugCodeCall, debugCodeCall, getNextId, getTraceId, getTraceObjectName, isDebugEnabled, isInfoEnabled, logAndConvert, quote, quoteArray, quoteBigDecimal, quoteBytes, quoteDate, quoteIntArray, quoteMap, quoteTime, quoteTimestamp, setTrace, unsupported

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.sql.Blob

    free
  • Constructor Details

    • JdbcBlob

      public JdbcBlob(JdbcConnection conn, org.h2.value.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 Details

    • length

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

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

      public byte[] getBytes(long pos, int length) throws SQLException
      Returns some bytes of the object.
      Specified by:
      getBytes in interface 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:
      SQLException
    • setBytes

      public int setBytes(long pos, byte[] bytes) throws 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 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:
      SQLException
    • setBytes

      public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException
      Sets some bytes of the object.
      Specified by:
      setBytes in interface 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:
      SQLException
    • getBinaryStream

      public InputStream getBinaryStream() throws SQLException
      Specified by:
      getBinaryStream in interface Blob
      Throws:
      SQLException
    • setBinaryStream

      public OutputStream setBinaryStream(long pos) throws 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 Blob
      Parameters:
      pos - where to start writing (the first byte is at position 1)
      Returns:
      an output stream
      Throws:
      SQLException
    • position

      public long position(byte[] pattern, long start) throws SQLException
      [Not supported] Searches a pattern and return the position.
      Specified by:
      position in interface 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:
      SQLException
    • position

      public long position(Blob blobPattern, long start) throws SQLException
      [Not supported] Searches a pattern and return the position.
      Specified by:
      position in interface 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:
      SQLException
    • getBinaryStream

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