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. By default, drivers implement 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. In addition, this interface has methods for updating
a BLOB value.
To release resources used by the Blob object, applications must call
either the free() or the close() method. Any attempt to
invoke a method other than free() or close() after the
Blob object has been closed, will result in a SQLException
being thrown.
All methods on the Blob interface must be fully implemented if the
JDBC driver supports the data type.
| Modifier and Type | Method and Description |
|---|---|
| public default void | close()
Implements java. Closes and releases the resources held by this |
| public void | |
| public InputStream | Returns: a stream containing theBLOB dataRetrieves the |
| public InputStream | Returns: InputStream through which
the partial Blob value can be read.the offset to the first byte of the partial value to be
retrieved. The first byte in the pos, long Blob is at position 1.the length in bytes of the partial value to be retrieved length)Returns an |
| public byte[] | Returns: a byte array containing up tolength
consecutive bytes from the BLOB value designated
by this Blob object, starting with the
byte at position posthe ordinal position of the first byte in the
pos, int BLOB value to be extracted; the first byte is at
position 1the number of consecutive bytes to be copied; the value
for length must be 0 or greater length)Retrieves all or part of the |
| public long | Returns: length of theBLOB in bytesReturns the number of bytes in the |
| public long | Returns: the position at which the pattern appears, else -1the byte array for which to search pattern, long the position at which to begin searching; the
first position is 1 start)Retrieves the byte position at which the specified byte array
|
| public long | Returns: the position at which the pattern begins, else -1the pattern, long Blob object designating
the BLOB value for which to searchthe position in the start)BLOB value
at which to begin searching; the first position is 1Retrieves the byte position in the |
| public OutputStream | Returns: ajava.io.OutputStream object to which data can
be writtenthe position in the pos)BLOB value at which
to start writing; the first position is 1Retrieves a stream that can be used to write to the |
| public int | Returns: the number of bytes writtenthe position in the pos, byte[] BLOB object at which
to start writing; the first position is 1the array of bytes to be written to the bytes)BLOB
value that this Blob object representsWrites the given array of bytes to the |
| public int | Returns: the number of bytes writtenthe position in the pos, byte[] BLOB object at which
to start writing; the first position is 1the array of bytes to be written to this bytes, int BLOB
objectthe offset into the array offset, int bytes at which
to start reading the bytes to be setthe number of bytes to be written to the len)BLOB
value from the array of bytes bytesWrites all or part of the given |
| public void | truncate(long
the length, in bytes, to which the len)BLOB value
that this Blob object represents should be truncatedTruncates the |
| close | back to summary |
|---|---|
| public default void close() throws SQLException Implements java. Closes and releases the resources held by this
If the Implementation Specification The default implementation calls the
| |
| free | back to summary |
|---|---|
| public void free() throws SQLException Closes and releases the resources held by this
If the
| |
| getBinaryStream | back to summary |
|---|---|
| public InputStream getBinaryStream() throws SQLException Retrieves the
| |
| getBinaryStream | back to summary |
|---|---|
| public InputStream getBinaryStream(long pos, long length) throws SQLException Returns an
| |
| getBytes | back to summary |
|---|---|
| public byte[] getBytes(long pos, int length) throws SQLException Retrieves all or part of the
| |
| length | back to summary |
|---|---|
| public long length() throws SQLException Returns the number of bytes in the
| |
| position | back to summary |
|---|---|
| public long position(byte[] pattern, long start) throws SQLException Retrieves the byte position at which the specified byte array
| |
| position | back to summary |
|---|---|
| public long position(Blob pattern, long start) throws SQLException Retrieves the byte position in the
| |
| setBinaryStream | back to summary |
|---|---|
| public OutputStream setBinaryStream(long pos) throws SQLException Retrieves a stream that can be used to write to the Note If the value specified for
| |
| setBytes | back to summary |
|---|---|
| public int setBytes(long pos, byte[] bytes) throws SQLException Writes the given array of bytes to the Note If the value specified for
| |
| setBytes | back to summary |
|---|---|
| public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException Writes all or part of the given Note If the value specified for
| |
| truncate | back to summary |
|---|---|
| public void truncate(long len) throws SQLException Truncates the Note If the value specified for
| |