public class Blob extends java.lang.Object implements java.sql.Blob, OutputStreamWatcher
Constructor and Description |
---|
Blob(byte[] data,
ExceptionInterceptor exceptionInterceptor)
Creates a BLOB encapsulating the given binary data
|
Blob(byte[] data,
ResultSetInternalMethods creatorResultSetToSet,
int columnIndexToSet)
Creates an updatable BLOB that can update in-place (not implemented yet).
|
Blob(ExceptionInterceptor exceptionInterceptor)
Creates a Blob without data
|
Modifier and Type | Method and Description |
---|---|
void |
free()
This method frees the
Blob object and releases the resources that
it holds. |
java.io.InputStream |
getBinaryStream()
Retrieves the BLOB designated by this Blob instance as a stream.
|
java.io.InputStream |
getBinaryStream(long pos,
long length)
Returns an
InputStream object that contains a partial Blob value,
starting with the byte specified by pos, which is length bytes in length. |
byte[] |
getBytes(long pos,
int length)
Returns as an array of bytes, part or all of the BLOB value that this
Blob object designates.
|
long |
length()
Returns the number of bytes in the BLOB value designated by this Blob
object.
|
long |
position(java.sql.Blob pattern,
long start)
Finds the position of the given pattern in this BLOB.
|
long |
position(byte[] 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(WatchableOutputStream out)
Called when the OutputStream being watched has .close() called
|
void |
truncate(long len)
Truncates the
BLOB value that this Blob
object represents to be len bytes in length. |
Blob(ExceptionInterceptor exceptionInterceptor)
Blob(byte[] data, ExceptionInterceptor exceptionInterceptor)
data
- DOCUMENT ME!Blob(byte[] data, ResultSetInternalMethods creatorResultSetToSet, int columnIndexToSet)
data
- DOCUMENT ME!creatorResultSetToSet
- DOCUMENT ME!columnIndexToSet
- DOCUMENT ME!public java.io.InputStream getBinaryStream() throws java.sql.SQLException
getBinaryStream
in interface java.sql.Blob
java.sql.SQLException
- if a database error occurspublic byte[] getBytes(long pos, int length) throws java.sql.SQLException
getBytes
in interface java.sql.Blob
pos
- where to start the part of the BLOBlength
- the length of the part of the BLOB you want returned.pos
and having a length of length
.java.sql.SQLException
- if a database error occurspublic long length() throws java.sql.SQLException
length
in interface java.sql.Blob
java.sql.SQLException
- if a database error occurspublic long position(byte[] pattern, long start) throws java.sql.SQLException
position
in interface java.sql.Blob
java.sql.SQLException
Blob.position(byte[], long)
public long position(java.sql.Blob pattern, long start) throws java.sql.SQLException
position
in interface java.sql.Blob
pattern
- the pattern to findstart
- where to start finding the patternjava.sql.SQLException
- if a database error occurspublic java.io.OutputStream setBinaryStream(long indexToWriteAt) throws java.sql.SQLException
setBinaryStream
in interface java.sql.Blob
java.sql.SQLException
setBinaryStream(long)
public int setBytes(long writeAt, byte[] bytes) throws java.sql.SQLException
setBytes
in interface java.sql.Blob
java.sql.SQLException
setBytes(long, byte[])
public int setBytes(long writeAt, byte[] bytes, int offset, int length) throws java.sql.SQLException
setBytes
in interface java.sql.Blob
java.sql.SQLException
setBytes(long, byte[], int, int)
public void streamClosed(byte[] byteData)
com.mysql.jdbc.OutputStreamWatcher#streamClosed(byte[])
public void streamClosed(WatchableOutputStream out)
OutputStreamWatcher
streamClosed
in interface OutputStreamWatcher
com.mysql.jdbc.OutputStreamWatcher#streamClosed(byte[])
public void truncate(long len) throws java.sql.SQLException
BLOB
value that this Blob
object represents to be len
bytes in length.
Note: If the value specified for len
is greater then the length+1 of the BLOB
value then the
behavior is undefined. Some JDBC drivers may throw a
SQLException
while other drivers may support this
operation.
truncate
in interface java.sql.Blob
len
- the length, in bytes, to which the BLOB
value
that this Blob
object represents should be truncatedjava.sql.SQLException
- if there is an error accessing the
BLOB
value or if len is less than 0SQLFeatureNotSupportedException
- if the JDBC driver does not support
this methodpublic void free() throws java.sql.SQLException
Blob
object and releases the resources that
it holds. The object is invalid once the free
method is called.
After free
has been called, any attempt to invoke a
method other than free
will result in a SQLException
being thrown. If free
is called multiple times, the subsequent
calls to free
are treated as a no-op.
free
in interface java.sql.Blob
java.sql.SQLException
- if an error occurs releasing
the Blob's resourcesSQLFeatureNotSupportedException
- if the JDBC driver does not support
this methodpublic java.io.InputStream getBinaryStream(long pos, long length) throws java.sql.SQLException
InputStream
object that contains a partial Blob
value,
starting with the byte specified by pos, which is length bytes in length.getBinaryStream
in interface java.sql.Blob
pos
- the offset to the first byte of the partial value to be retrieved.
The first byte in the Blob
is at position 1length
- the length in bytes of the partial value to be retrievedInputStream
through which the partial Blob
value can be read.java.sql.SQLException
- if pos is less than 1 or if pos is greater than the number of bytes
in the Blob
or if pos + length is greater than the number of bytes
in the Blob
SQLFeatureNotSupportedException
- if the JDBC driver does not support
this method