| java.lang.Object com.mysql.jdbc.Blob
Blob | public class Blob implements java.sql.Blob,OutputStreamWatcher(Code) | | 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.
author: Mark Matthews version: $Id: Blob.java 6437 2007-05-24 20:17:01Z mmatthews $ |
Constructor Summary | |
| Blob() | | Blob(byte[] data) | | Blob(byte[] data, ResultSetInternalMethods creatorResultSetToSet, int columnIndexToSet) Creates an updatable BLOB that can update in-place (not implemented yet). |
Method Summary | |
public synchronized void | free() This method frees the Blob object and releases the resources that
it holds. | public synchronized java.io.InputStream | getBinaryStream() Retrieves the BLOB designated by this Blob instance as a stream. | public synchronized 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. | public synchronized byte[] | getBytes(long pos, int length) Returns as an array of bytes, part or all of the BLOB value that this
Blob object designates.
Parameters: pos - where to start the part of the BLOB Parameters: length - the length of the part of the BLOB you want returned. | public synchronized long | length() Returns the number of bytes in the BLOB value designated by this Blob
object. | public synchronized long | position(byte[] pattern, long start) | public synchronized long | position(java.sql.Blob pattern, long start) Finds the position of the given pattern in this BLOB. | public synchronized OutputStream | setBinaryStream(long indexToWriteAt) | public synchronized int | setBytes(long writeAt, byte[] bytes) | public synchronized int | setBytes(long writeAt, byte[] bytes, int offset, int length) | public synchronized void | streamClosed(byte[] byteData) | public synchronized void | streamClosed(WatchableOutputStream out) | public synchronized void | truncate(long len) Truncates the 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. |
Blob | Blob()(Code) | | Creates a Blob without data
|
Blob | Blob(byte[] data)(Code) | | Creates a BLOB encapsulating the given binary data
Parameters: data - DOCUMENT ME! |
Blob | Blob(byte[] data, ResultSetInternalMethods creatorResultSetToSet, int columnIndexToSet)(Code) | | Creates an updatable BLOB that can update in-place (not implemented yet).
Parameters: data - DOCUMENT ME! Parameters: creatorResultSetToSet - DOCUMENT ME! Parameters: columnIndexToSet - DOCUMENT ME! |
free | public synchronized void free() throws SQLException(Code) | | This method frees the 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.
throws: SQLException - if an error occurs releasingthe Blob's resources exception: SQLFeatureNotSupportedException - if the JDBC driver does not supportthis method since: 1.6 |
getBinaryStream | public synchronized java.io.InputStream getBinaryStream() throws SQLException(Code) | | Retrieves the BLOB designated by this Blob instance as a stream.
this BLOB represented as a binary stream of bytes. throws: SQLException - if a database error occurs |
getBinaryStream | public synchronized InputStream getBinaryStream(long pos, long length) throws SQLException(Code) | | Returns an InputStream object that contains a partial Blob value,
starting with the byte specified by pos, which is length bytes in length.
Parameters: pos - the offset to the first byte of the partial value to be retrieved.The first byte in the Blob is at position 1 Parameters: length - the length in bytes of the partial value to be retrieved InputStream through which the partial Blob value can be read. throws: SQLException - if pos is less than 1 or if pos is greater than the number of bytesin the Blob or if pos + length is greater than the number of bytes in the Blob exception: SQLFeatureNotSupportedException - if the JDBC driver does not supportthis method since: 1.6 |
getBytes | public synchronized byte[] getBytes(long pos, int length) throws SQLException(Code) | | Returns as an array of bytes, part or all of the BLOB value that this
Blob object designates.
Parameters: pos - where to start the part of the BLOB Parameters: length - the length of the part of the BLOB you want returned. the bytes stored in the blob starting at positionpos and having a length of length . throws: SQLException - if a database error occurs |
length | public synchronized long length() throws SQLException(Code) | | Returns the number of bytes in the BLOB value designated by this Blob
object.
the length of this blob throws: SQLException - if a database error occurs |
position | public synchronized long position(java.sql.Blob pattern, long start) throws SQLException(Code) | | Finds the position of the given pattern in this BLOB.
Parameters: pattern - the pattern to find Parameters: start - where to start finding the pattern the position where the pattern is found in the BLOB, -1 if notfound throws: SQLException - if a database error occurs |
truncate | public synchronized void truncate(long len) throws SQLException(Code) | | Truncates the 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.
Parameters: len - the length, in bytes, to which the BLOB valuethat this Blob object represents should be truncated exception: SQLException - if there is an error accessing theBLOB value or if len is less than 0 exception: SQLFeatureNotSupportedException - if the JDBC driver does not supportthis method since: 1.4 |
|
|