Serializable
, Blob
public final class SQLServerBlob extends Object implements Blob, Serializable
Constructor | Description |
---|---|
SQLServerBlob(SQLServerConnection connection,
byte[] data) |
Deprecated.
Use
SQLServerConnection.createBlob() instead. |
Modifier and Type | Method | Description |
---|---|---|
void |
free() |
Frees this Blob object and releases the resources that it holds.
|
InputStream |
getBinaryStream() |
|
InputStream |
getBinaryStream(long pos,
long length) |
|
byte[] |
getBytes(long pos,
int length) |
Retrieves all or part of the BLOB value that this Blob object represents, as an array of bytes.
|
long |
length() |
Return the length of the BLOB
|
long |
position(byte[] bPattern,
long start) |
Retrieves the byte position at which the specified byte array pattern begins within the BLOB value that this Blob object represents.
|
long |
position(Blob pattern,
long start) |
Retrieves the byte position in the BLOB value designated by this Blob object at which pattern begins.
|
OutputStream |
setBinaryStream(long pos) |
Retrieves a stream that can be used to write to the BLOB value that this Blob object represents
|
int |
setBytes(long pos,
byte[] bytes) |
Writes the given array of bytes into the Blob starting at position pos, and returns the number of bytes written.
|
int |
setBytes(long pos,
byte[] bytes,
int offset,
int len) |
Writes all or part of the given byte array to the BLOB value that this Blob object represents and returns the number of bytes written.
|
String |
toString() |
|
void |
truncate(long len) |
Truncate a BLOB
|
@Deprecated public SQLServerBlob(SQLServerConnection connection, byte[] data)
SQLServerConnection.createBlob()
instead.connection
- the database connection this blob is implemented ondata
- the BLOB's datapublic void free() throws SQLException
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 Blob
SQLException
public InputStream getBinaryStream() throws SQLException
getBinaryStream
in interface Blob
SQLException
public InputStream getBinaryStream(long pos, long length) throws SQLException
getBinaryStream
in interface Blob
SQLException
public byte[] getBytes(long pos, int length) throws SQLException
getBytes
in interface Blob
pos
- - the ordinal position of the first byte in the BLOB value to be extracted; the first byte is at position 1length
- - the number of consecutive bytes to be copied; the value for length must be 0 or greaterSQLException
- - if there is an error accessing the BLOB value; if pos is less than 1 or length is less than 0public long length() throws SQLException
length
in interface Blob
SQLException
- when an error occurspublic long position(Blob pattern, long start) throws SQLException
position
in interface Blob
pattern
- - the Blob object designating the BLOB value for which to searchstart
- - the position in the BLOB value at which to begin searching; the first position is 1SQLException
- - if there is an error accessing the BLOB value or if start is less than 1public long position(byte[] bPattern, long start) throws SQLException
position
in interface Blob
bPattern
- - the byte array for which to searchstart
- - the position at which to begin searching; the first position is 1SQLException
- - if there is an error accessing the BLOB or if start is less than 1public void truncate(long len) throws SQLException
truncate
in interface Blob
len
- the new length for the BLOBSQLException
- when an error occurspublic OutputStream setBinaryStream(long pos) throws SQLException
setBinaryStream
in interface Blob
pos
- - the position in the BLOB value at which to start writing; the first position is 1SQLException
- - if there is an error accessing the BLOB value or if pos is less than 1public int setBytes(long pos, byte[] bytes) throws SQLException
setBytes
in interface Blob
pos
- the position (1 based) in the Blob object at which to start writing the data.bytes
- the array of bytes to be written into the Blob.SQLException
- if there is an error accessing the BLOB value.public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException
setBytes
in interface Blob
pos
- - the position in the BLOB object at which to start writing; the first position is 1bytes
- - the array of bytes to be written to this BLOB object.offset
- - the offset (0-based) into the array bytes at which to start reading the bytes to setlen
- - the number of bytes to be written to the BLOB value from the array of bytes bytesSQLException
- - if there is an error accessing the BLOB value or if pos is less than 1Copyright © 2018 Microsoft Corporation. All rights reserved.