public class BlobImpl extends Object implements Blob
The representation (mapping) in the Java 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.
Constructor and Description |
---|
BlobImpl(byte[] bytes)
Constructor taking a byte array.
|
BlobImpl(InputStream stream)
Constructor taking an InputStream.
|
BlobImpl(Object obj)
Constructor taking a serialised object.
|
Modifier and Type | Method and Description |
---|---|
void |
free()
Free the Blob object and releases the resources that it holds.
|
InputStream |
getBinaryStream() |
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) |
Object |
getObject()
Accessor for the Object.
|
long |
length() |
long |
position(Blob pattern,
long start) |
long |
position(byte[] pattern,
long start) |
OutputStream |
setBinaryStream(long value) |
int |
setBytes(long value,
byte[] bytes) |
int |
setBytes(long value,
byte[] bytes,
int pos,
int length) |
void |
truncate(long value) |
public BlobImpl(Object obj) throws IOException
obj
- The serialised object.IOException
- if an error occurspublic BlobImpl(byte[] bytes)
bytes
- The byte arraypublic BlobImpl(InputStream stream)
stream
- The InputStreampublic Object getObject() throws SQLException
SQLException
- if an error occurspublic long length() throws SQLException
length
in interface Blob
SQLException
public byte[] getBytes(long pos, int length) throws SQLException
getBytes
in interface Blob
SQLException
public int setBytes(long value, byte[] bytes, int pos, int length) throws SQLException
setBytes
in interface Blob
SQLException
public void truncate(long value) throws SQLException
truncate
in interface Blob
SQLException
public int setBytes(long value, byte[] bytes) throws SQLException
setBytes
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
pos
- 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 retrievedSQLException
public OutputStream setBinaryStream(long value) throws SQLException
setBinaryStream
in interface Blob
SQLException
public void free() throws SQLException
free
in interface Blob
SQLException
- if an error occurspublic long position(byte[] pattern, long start) throws SQLException
position
in interface Blob
SQLException
public long position(Blob pattern, long start) throws SQLException
position
in interface Blob
SQLException
Copyright © 2015. All rights reserved.