public interface Blob
A Blob object is a pointer to a binary large object (BLOB) value in a table column. It is valid only during the transaction in which it was created. The corresponding SQL type is SQL BLOB.
getBinaryStream
public java.io.InputStream getBinaryStream() throws SQLException
This gets the BLOB’S content as an input stream.
Returns: A stream containing the BLOB data. A SQLException is thrown if an error occurs while accessing this data.
getBytes
public byte[] getBytes(long pos, int length) throws SQLException
This gets a part of the BLOB’S content as an array of bytes. A starting point and length are provided as parameters.
Parameters:
pos: | The first byte in the BLOB value to be returned begins at 1. |
length: | The number of bytes to be returned in the array. |
Returns: A byte array containing up to length bytes from the BLOB, starting at position pos. A SQLException is thrown if an error occurs while accessing this value.
length
public long length() throws SQLException
This gets the number of bytes in the BLOB value referenced by the Blob object.
Returns: The length of the BLOB in bytes. A SQLException is thrown if an error occurs while accessing this value.
position
public long position(byte[] pattern, long start) throws SQLException
This searches for a position within the BLOB’S bytes using an array of bytes as a pattern. A starting point is provided. No wildcards bytes are available.
Parameters:
pattern: | The byte array containing the bytes to search in the BLOB. |
start: | The start position; the first byte is at position 1. |
Returns: The position at which the pattern appears or -1 if the pattern isn’t found. A SQLException is thrown if an error occurs while accessing this value.
position
public long position(Blob pattern, long start) throws SQLException
This searches for a position within the BLOB’S bytes using another BLOB as a pattern. A starting point is provided. No wildcards are available.
Parameters:
pattern: | The BLOB containing the bytes to search in the current BLOB. |
start: | The start position; the first byte is at position 1. |
Returns: The position at which the pattern appears or -1 if the pattern isn’t found. A SQLException is thrown if an error occurs while accessing this value.
setBinaryStream
public java.io.OutputStream setBinaryStream(long pos) throws SQLException
This returns an output stream that can be used to write any number of bytes to the BLOB at position pos.
Parameters:
pos: | The position in the BLOB object at which to start writing |
Returns: The output stream to which data can be written. A SQLException is thrown if an error occurs while accessing this value.
setBytes
public int setBytes(long pos, byte[] bytes) throws SQLException
This writes an array of bytes to the BLOB starting at position pos.
Parameters:
pos: | The position in the BLOB object at which to start writing |
bytes: | The array of bytes to be written to the BLOB object |
Returns: The number of bytes written to the BLOB object. A SQLException is thrown if an error occurs while accessing this value.
setBytes
public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException
This writes a subarray of bytes to the BLOB starting at position pos. A SQLException is thrown if an error occurs while accessing this value.
Parameters:
pos: | The position in the BLOB object at which to start writing |
bytes: | The array of bytes to be written to the BLOB object |
offset: | The offset into the array bytes to start reading the bytes to be set |
len: | The number of bytes to be written to the BLOB object |
Returns: The number of bytes written to the BLOB object. A SQLException is thrown if an error occurs while accessing this value.
truncate
public void truncate(long len) throws SQLException
This method is used to truncate the current BLOB to length len. A SQLException is thrown if an error occurs while accessing this value.
Parameters:
len: | The length, in bytes, to which the current BLOB must be truncated |