Name

Blob

Synopsis

The Blob interface encapsulates a SQL BLOB (binary large object) field. The interface actually contains a pointer to the BLOB within the database, rather than the complete (and potentially very large) object. Data can be retrieved via a java.io.InputStream returned by getInputStream() or as an array of bytes returned by getBytes(). The length() method returns the number of bytes in the BLOB. The position() methods scan the contents of the Blob for a particular content sequence, represented by either another Blob object or a byte array. (The position() methods do not provide the current read-index within the BLOB). JDBC 3.0 adds the setBinaryStream() and setBytes() methods, which allow JDBC applications to create and edit BLOB data as well as reading it.

public interface Blob {
// Public Instance Methods
   public abstract java.io.InputStream getBinaryStream(
        ) throws SQLException;  
   public abstract byte[] getBytes(long pos, 
        int length) throws SQLException;  
   public abstract long length() throws SQLException;  
   public abstract long position(Blob pattern, 
        long start) throws SQLException;  
   public abstract long position(byte[] pattern, 
        long start) throws SQLException;  
   public abstract java.io.OutputStream setBinaryStream(         // 1.4
        long pos) throws SQLException;  
   public abstract int setBytes(long pos,                        // 1.4
        byte[] bytes) throws SQLException;  
   public abstract int setBytes(long pos,                        // 1.4
        byte[] bytes, int offset, 
        int len) throws SQLException;  
   public abstract void truncate(                                // 1.4

Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.