java.io.Serializable
, java.sql.Blob
public final class SQLServerBlob
extends java.lang.Object
implements java.sql.Blob, java.io.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.
|
java.io.InputStream |
getBinaryStream() |
|
java.io.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(java.sql.Blob pattern,
long start) |
Retrieves the byte position in the BLOB value designated by this Blob object at which pattern begins.
|
java.io.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.
|
java.lang.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 final java.lang.String toString()
toString
in class java.lang.Object
public void free() throws java.sql.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 java.sql.Blob
java.sql.SQLException
public java.io.InputStream getBinaryStream() throws java.sql.SQLException
getBinaryStream
in interface java.sql.Blob
java.sql.SQLException
public java.io.InputStream getBinaryStream(long pos, long length) throws java.sql.SQLException
getBinaryStream
in interface java.sql.Blob
java.sql.SQLException
public byte[] getBytes(long pos, int length) throws java.sql.SQLException
getBytes
in interface java.sql.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 greaterjava.sql.SQLException
- - if there is an error accessing the BLOB value; if pos is less than 1 or length is less than 0public long length() throws java.sql.SQLException
length
in interface java.sql.Blob
java.sql.SQLException
- when an error occurspublic long position(java.sql.Blob pattern, long start) throws java.sql.SQLException
position
in interface java.sql.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 1java.sql.SQLException
- - if there is an error accessing the BLOB value or if start is less than 1public long position(byte[] bPattern, long start) throws java.sql.SQLException
position
in interface java.sql.Blob
bPattern
- - the byte array for which to searchstart
- - the position at which to begin searching; the first position is 1java.sql.SQLException
- - if there is an error accessing the BLOB or if start is less than 1public void truncate(long len) throws java.sql.SQLException
truncate
in interface java.sql.Blob
len
- the new length for the BLOBjava.sql.SQLException
- when an error occurspublic java.io.OutputStream setBinaryStream(long pos) throws java.sql.SQLException
setBinaryStream
in interface java.sql.Blob
pos
- - the position in the BLOB value at which to start writing; the first position is 1java.sql.SQLException
- - if there is an error accessing the BLOB value or if pos is less than 1public int setBytes(long pos, byte[] bytes) throws java.sql.SQLException
setBytes
in interface java.sql.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.java.sql.SQLException
- if there is an error accessing the BLOB value.public int setBytes(long pos, byte[] bytes, int offset, int len) throws java.sql.SQLException
setBytes
in interface java.sql.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 bytesjava.sql.SQLException
- - if there is an error accessing the BLOB value or if pos is less than 1Copyright © 2018 Microsoft Corporation. All rights reserved.