|
MySQL Connector/J size='-1'>5.1.6 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.mysql.jdbc.Blob
public class Blob
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.
| Method Summary | |
|---|---|
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(com.mysql.jdbc.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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public java.io.InputStream getBinaryStream()
throws java.sql.SQLException
getBinaryStream in interface java.sql.Blobjava.sql.SQLException - if a database error occurs
public byte[] getBytes(long pos,
int length)
throws java.sql.SQLException
getBytes in interface java.sql.Blobpos - 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 occurs
public long length()
throws java.sql.SQLException
length in interface java.sql.Blobjava.sql.SQLException - if a database error occurs
public long position(byte[] pattern,
long start)
throws java.sql.SQLException
position in interface java.sql.Blobjava.sql.SQLExceptionBlob.position(byte[], long)
public long position(java.sql.Blob pattern,
long start)
throws java.sql.SQLException
position in interface java.sql.Blobpattern - the pattern to findstart - where to start finding the pattern
java.sql.SQLException - if a database error occurs
public java.io.OutputStream setBinaryStream(long indexToWriteAt)
throws java.sql.SQLException
setBinaryStream in interface java.sql.Blobjava.sql.SQLExceptionsetBinaryStream(long)
public int setBytes(long writeAt,
byte[] bytes)
throws java.sql.SQLException
setBytes in interface java.sql.Blobjava.sql.SQLExceptionsetBytes(long, byte[])
public int setBytes(long writeAt,
byte[] bytes,
int offset,
int length)
throws java.sql.SQLException
setBytes in interface java.sql.Blobjava.sql.SQLExceptionsetBytes(long, byte[], int, int)public void streamClosed(byte[] byteData)
com.mysql.jdbc.OutputStreamWatcher#streamClosed(byte[])public void streamClosed(com.mysql.jdbc.WatchableOutputStream out)
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.Bloblen - the length, in bytes, to which the BLOB value
that this Blob object represents should be truncated
java.sql.SQLException - if there is an error accessing the
BLOB value or if len is less than 0
SQLFeatureNotSupportedException - if the JDBC driver does not support
this method
public 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.Blobjava.sql.SQLException - if an error occurs releasing
the Blob's resources
SQLFeatureNotSupportedException - if the JDBC driver does not support
this method
public 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.Blobpos - 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 retrieved
InputStream 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
|
MySQL Connector/J size='-1'>5.1.6 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||