Class Blob

java.lang.Object
com.mysql.cj.jdbc.Blob
All Implemented Interfaces:
OutputStreamWatcher, java.sql.Blob

public class Blob
extends java.lang.Object
implements java.sql.Blob, OutputStreamWatcher
The representation (mapping) in the JavaTM programming language of an SQL BLOB value. An SQL BLOB is a built-in type that stores a Binary Large Object as a column value in a row of a database table. The driver implements Blob using an SQL locator(BLOB), which means that a Blob object contains a logical pointer to the SQL BLOB data rather than the data itself. A Blob object is valid for the duration of the transaction in which is was created. Methods in the interfaces ResultSet, CallableStatement, and PreparedStatement, such as getBlob and setBlob allow a programmer to access an SQL BLOB value. The Blob interface provides methods for getting the length of an SQL BLOB (Binary Large Object) value, for materializing a BLOB value on the client, and for determining the position of a pattern of bytes within a BLOB value. This class is new in the JDBC 2.0 API.
  • Constructor Summary

    Constructors 
    Constructor Description
    Blob​(byte[] data, ExceptionInterceptor exceptionInterceptor)
    Creates a BLOB encapsulating the given binary data
  • Method Summary

    Modifier and Type Method Description
    void free()  
    java.io.InputStream getBinaryStream()  
    java.io.InputStream getBinaryStream​(long pos, long length)  
    byte[] getBytes​(long pos, int length)  
    long length()  
    long position​(byte[] pattern, long start)  
    long position​(java.sql.Blob pattern, long start)  
    java.io.OutputStream setBinaryStream​(long indexToWriteAt)  
    int setBytes​(long writeAt, byte[] bytes)  
    int setBytes​(long writeAt, byte[] bytes, int offset, int length)  
    void streamClosed​(byte[] byteData)  
    void streamClosed​(WatchableStream out)
    Called when the OutputStream being watched has .close() called
    void truncate​(long len)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Blob

      public Blob​(byte[] data, ExceptionInterceptor exceptionInterceptor)
      Creates a BLOB encapsulating the given binary data
      Parameters:
      data - data to fill the Blob
      exceptionInterceptor - exception interceptor
  • Method Details

    • getBinaryStream

      public java.io.InputStream getBinaryStream() throws java.sql.SQLException
      Specified by:
      getBinaryStream in interface java.sql.Blob
      Throws:
      java.sql.SQLException
    • getBytes

      public byte[] getBytes​(long pos, int length) throws java.sql.SQLException
      Specified by:
      getBytes in interface java.sql.Blob
      Throws:
      java.sql.SQLException
    • length

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

      public long position​(byte[] pattern, long start) throws java.sql.SQLException
      Specified by:
      position in interface java.sql.Blob
      Throws:
      java.sql.SQLException
    • position

      public long position​(java.sql.Blob pattern, long start) throws java.sql.SQLException
      Specified by:
      position in interface java.sql.Blob
      Throws:
      java.sql.SQLException
    • setBinaryStream

      public java.io.OutputStream setBinaryStream​(long indexToWriteAt) throws java.sql.SQLException
      Specified by:
      setBinaryStream in interface java.sql.Blob
      Throws:
      java.sql.SQLException
    • setBytes

      public int setBytes​(long writeAt, byte[] bytes) throws java.sql.SQLException
      Specified by:
      setBytes in interface java.sql.Blob
      Throws:
      java.sql.SQLException
    • setBytes

      public int setBytes​(long writeAt, byte[] bytes, int offset, int length) throws java.sql.SQLException
      Specified by:
      setBytes in interface java.sql.Blob
      Throws:
      java.sql.SQLException
    • streamClosed

      public void streamClosed​(byte[] byteData)
    • streamClosed

      public void streamClosed​(WatchableStream out)
      Description copied from interface: OutputStreamWatcher
      Called when the OutputStream being watched has .close() called
      Specified by:
      streamClosed in interface OutputStreamWatcher
      Parameters:
      out - WatchableStream
    • truncate

      public void truncate​(long len) throws java.sql.SQLException
      Specified by:
      truncate in interface java.sql.Blob
      Throws:
      java.sql.SQLException
    • free

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

      public java.io.InputStream getBinaryStream​(long pos, long length) throws java.sql.SQLException
      Specified by:
      getBinaryStream in interface java.sql.Blob
      Throws:
      java.sql.SQLException