| java.lang.Object org.apache.derby.impl.jdbc.ConnectionChild org.apache.derby.impl.jdbc.EmbedBlob
EmbedBlob | final class EmbedBlob extends ConnectionChild implements Blob(Code) | | Implements java.sql.Blob (see the JDBC 2.0 spec).
A blob sits on top of a BINARY, VARBINARY or LONG VARBINARY column.
If its data is small (less than 1 page) it is a byte array taken from
the SQLBit class. If it is large (more than 1 page) it is a long column
in the database. The long column is accessed as a stream, and is implemented
in store as an OverflowInputStream. The Resetable interface allows sending
messages to that stream to initialize itself (reopen its container and
lock the corresponding row) and to reset itself to the beginning.
NOTE: In the case that the data is large, it is represented as a stream.
This stream is returned to the user in the getBinaryStream() method.
This means that we have limited control over the state of the stream,
since the user can read bytes from it at any time. Thus all methods
here reset the stream to the beginning before doing any work.
CAVEAT: The methods may not behave correctly if a user sets up
multiple threads and sucks data from the stream (returned from
getBinaryStream()) at the same time as calling the Blob methods.
Supports
- JSR169 - no subsetting for java.sql.Blob
- JDBC 2.0
- JDBC 3.0 - no new dependencies on new JDBC 3.0 or JDK 1.4 classes,
new update methods can safely be added into implementation.
|
Method Summary | |
protected void | finalize() | public void | free() This method frees the Blob object and releases the resources that
it holds. | public java.io.InputStream | getBinaryStream() Retrieves the BLOB designated by this
Blob instance as a stream. | public 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.
Parameters: pos - the offset to the first byte of the partial value to be retrieved. | public byte[] | getBytes(long startPos, int length) Returns as an array of bytes part or all of the BLOB
value that this Blob object designates. | public long | length() Returns the number of bytes in the BLOB value
designated by this Blob object. | public long | position(byte[] pattern, long start) Determines the byte position at which the specified byte
pattern begins within the BLOB
value that this Blob object represents. | public long | position(Blob pattern, long start) Determines the byte position in the BLOB value
designated by this Blob object at which
pattern begins. | public java.io.OutputStream | setBinaryStream(long pos) JDBC 3.0
Retrieves a stream that can be used to write to the BLOB value that this
Blob object represents. | public int | setBytes(long pos, byte[] bytes) JDBC 3.0
Writes the given array of bytes to the BLOB value that this Blob object
represents, starting at position pos, and returns the number of bytes written. | public int | setBytes(long pos, byte[] bytes, int offset, int len) JDBC 3.0
Writes all or part of the given array of byte array to the BLOB value that
this Blob object represents and returns the number of bytes written. | public void | truncate(long len) JDBC 3.0
Truncates the BLOB value that this Blob object represents to be len bytes
in length. |
EmbedBlob | EmbedBlob(byte[] blobBytes, EmbedConnection con)(Code) | | This constructor is used to create a empty Blob object. It is used by the
Connection interface method createBlob().
Parameters: blobBytes - A byte array containing the data to be stores in the Blob. Parameters: con - The EmbedConnection object associated with this Blob object. |
finalize | protected void finalize()(Code) | | |
free | public 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. 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 |
getBinaryStream | public java.io.InputStream getBinaryStream() throws SQLException(Code) | | Retrieves the BLOB designated by this
Blob instance as a stream.
a stream containing the BLOB data exception: SQLException - if there is an error accessing theBLOB |
getBinaryStream | public 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 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 bytes in the Blob or if pos + length isgreater than the number of bytes in the Blob |
getBytes | public byte[] getBytes(long startPos, int length) throws SQLException(Code) | | Returns as an array of bytes part or all of the BLOB
value that this Blob object designates. The byte
array contains up to length consecutive bytes
starting at position startPos .
The starting position must be between 1 and the length
of the BLOB plus 1. This allows for zero-length BLOB values, from
which only zero-length byte arrays can be returned.
If a larger length is requested than there are bytes available,
characters from the start position to the end of the BLOB are returned.
Parameters: startPos - the ordinal position of the first byte in theBLOB value to be extracted; the first byte is atposition 1 Parameters: length - is the number of consecutive bytes to be copied a byte array containing up to length consecutive bytes from the BLOB value designatedby this Blob object, starting with thebyte at position startPos . exception: SQLException - if there is an error accessing theBLOB NOTE: If the starting position is the length of the BLOB plus 1,zero bytess are returned regardless of the length requested. |
length | public long length() throws SQLException(Code) | | Returns the number of bytes in the BLOB value
designated by this Blob object.
length of the BLOB in bytes exception: SQLException - if there is an error accessing thelength of the BLOB |
position | public long position(byte[] pattern, long start) throws SQLException(Code) | | Determines the byte position at which the specified byte
pattern begins within the BLOB
value that this Blob object represents. The
search for patternstart
Parameters: pattern - the byte array for which to search Parameters: start - the position at which to begin searching; thefirst position is 1 the position at which the pattern appears, else -1. exception: SQLException - if there is an error accessing theBLOB |
position | public long position(Blob pattern, long start) throws SQLException(Code) | | Determines the byte position in the BLOB value
designated by this Blob object at which
pattern begins. The search begins at position
start .
Parameters: pattern - the Blob object designatingthe BLOB value for which to search Parameters: start - the position in the BLOB valueat which to begin searching; the first position is 1 the position at which the pattern begins, else -1 exception: SQLException - if there is an error accessing theBLOB |
setBinaryStream | public java.io.OutputStream setBinaryStream(long pos) throws SQLException(Code) | | JDBC 3.0
Retrieves a stream that can be used to write to the BLOB value that this
Blob object represents. The stream begins at position pos.
Parameters: pos - - the position in the BLOB object at which to start writing a java.io.OutputStream object to which data can be written exception: SQLException - Feature not implemented for now. |
setBytes | public int setBytes(long pos, byte[] bytes) throws SQLException(Code) | | JDBC 3.0
Writes the given array of bytes to the BLOB value that this Blob object
represents, starting at position pos, and returns the number of bytes written.
Parameters: pos - - the position in the BLOB object at which to start writing Parameters: bytes - - the array of bytes to be written to the BLOB value that thisBlob object represents the number of bytes written exception: SQLException - Feature not implemented for now. |
setBytes | public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException(Code) | | JDBC 3.0
Writes all or part of the given array of byte array to the BLOB value that
this Blob object represents and returns the number of bytes written.
Writing starts at position pos in the BLOB value; len bytes from the given
byte array are written.
Parameters: pos - - the position in the BLOB object at which to start writing Parameters: bytes - - the array of bytes to be written to the BLOB value that thisBlob object represents Parameters: offset - - the offset into the array bytes at which to start readingthe bytes to be set Parameters: len - - the number of bytes to be written to the BLOB value from thearray of bytes bytes the number of bytes written exception: SQLException - Feature not implemented for now. |
truncate | public void truncate(long len) throws SQLException(Code) | | JDBC 3.0
Truncates the BLOB value that this Blob object represents to be len bytes
in length.
Parameters: len - - the length, in bytes, to which the BLOB value that this Blobobject represents should be truncated exception: SQLException - Feature not implemented for now. |
|
|