|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.firebirdsql.jdbc.FBBlob
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.
Nested Class Summary | |
class |
FBBlob.FBBlobInputStream
|
class |
FBBlob.FBBlobOutputStream
|
Nested classes inherited from class org.firebirdsql.jdbc.FirebirdBlob |
FirebirdBlob.BlobInputStream, FirebirdBlob.BlobOutputStream |
Field Summary | |
static int |
READ_FULLY_BUFFER_SIZE
|
Constructor Summary | |
FBBlob(AbstractConnection c)
Create new Blob instance. |
|
FBBlob(AbstractConnection c,
long blob_id)
Create instance of this class to access existing Blob. |
Method Summary | |
void |
close()
Close this Blob object. |
void |
copyCharacterStream(java.io.Reader inputStream,
int length,
java.lang.String encoding)
|
void |
copyStream(java.io.InputStream inputStream,
int length)
|
FirebirdBlob |
detach()
Detach this blob. |
java.io.InputStream |
getBinaryStream()
Retrieves the BLOB designated by this
Blob instance as a stream. |
long |
getBlobId()
|
byte[] |
getBytes(long pos,
int length)
Returns as an array of bytes, part or all of the BLOB
value that this Blob object designates. |
byte[] |
getInfo(byte[] items,
int buffer_length)
Get information about this Blob. |
java.lang.Object |
getSynchronizationObject()
Get synchronization object that will be used to synchronize multithreaded access to the database. |
boolean |
isSegmented()
Check if blob is segmented. |
long |
length()
Returns the number of bytes in the BLOB value
designated by this Blob object. |
long |
position(java.sql.Blob pattern,
long start)
Determines the byte position in the BLOB value
designated by this Blob object at which
pattern begins. |
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. |
java.io.OutputStream |
setBinaryStream(long pos)
Retrieves a stream that can be used to write to the Blob value that this object represents. |
int |
setBytes(long param1,
byte[] param2)
|
int |
setBytes(long param1,
byte[] param2,
int param3,
int param4)
|
void |
truncate(long param1)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int READ_FULLY_BUFFER_SIZE
Constructor Detail |
public FBBlob(AbstractConnection c)
c
- connection that will be used to write data to blob.public FBBlob(AbstractConnection c, long blob_id)
c
- connection that will be used to access Blob.blob_id
- ID of the Blob.Method Detail |
public java.lang.Object getSynchronizationObject()
getSynchronizationObject
in interface Synchronizable
public void close() throws java.io.IOException
java.io.IOException
- if at least one of the stream raised an exception
when closed.public byte[] getInfo(byte[] items, int buffer_length) throws java.sql.SQLException
items
- items in which we are interested.buffer_length
- buffer where information will be stored.
java.sql.SQLException
- if something went wrong.public long length() throws java.sql.SQLException
BLOB
value
designated by this Blob
object.
length
in interface java.sql.Blob
BLOB
in bytes
java.sql.SQLException
- if there is an error accessing the
length of the BLOB
public boolean isSegmented() throws java.sql.SQLException
isSegmented
in interface FirebirdBlob
true
if this blob is segmented,
otherwise false
java.sql.SQLException
- if something went wrong.public FirebirdBlob detach() throws java.sql.SQLException
Note, detached blob will not remember the stream position of this object. This means that you cannot start reading data from the blob, then detach it, and then continue reading. Reading from detached blob will begin at the blob start.
detach
in interface FirebirdBlob
FBBlob
that is not under result set control.
java.sql.SQLException
- if Blob cannot be detached.public byte[] getBytes(long pos, int length) throws java.sql.SQLException
BLOB
value that this Blob
object designates. The byte
array contains up to length
consecutive bytes
starting at position pos
.
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
length
consecutive bytes from the BLOB
value designated
by this Blob
object, starting with the
byte at position pos
java.sql.SQLException
- if there is an error accessing the
BLOB
public java.io.InputStream getBinaryStream() throws java.sql.SQLException
BLOB
designated by this
Blob
instance as a stream.
getBinaryStream
in interface java.sql.Blob
BLOB
data
java.sql.SQLException
- if there is an error accessing the
BLOB
public long position(byte[] pattern, long start) throws java.sql.SQLException
pattern
begins within the BLOB
value that this Blob
object represents. The
search for pattern
begins at position
start
.
position
in interface java.sql.Blob
pattern
- the byte array for which to searchstart
- the position at which to begin searching; the
first position is 1
java.sql.SQLException
- if there is an error accessing the
BLOB
public long position(java.sql.Blob pattern, long start) throws java.sql.SQLException
BLOB
value
designated by this Blob
object at which
pattern
begins. The search begins at position
start
.
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 1
java.sql.SQLException
- if there is an error accessing the
BLOB
public void truncate(long param1) throws java.sql.SQLException
truncate
in interface java.sql.Blob
param1
- java.sql.SQLException
- public int setBytes(long param1, byte[] param2) throws java.sql.SQLException
setBytes
in interface java.sql.Blob
param1
- param2
- java.sql.SQLException
- public int setBytes(long param1, byte[] param2, int param3, int param4) throws java.sql.SQLException
setBytes
in interface java.sql.Blob
param1
- param2
- param3
- param4
- java.sql.SQLException
- public java.io.OutputStream setBinaryStream(long pos) throws java.sql.SQLException
FirebirdBlob
position
.
This method is directly copied from JDBC 3.0 classes to make it available in JDBC 2.0 environment.
setBinaryStream
in interface FirebirdBlob
pos
- The position in the blob to start writing.
java.sql.SQLException
- public long getBlobId() throws java.sql.SQLException
java.sql.SQLException
public void copyStream(java.io.InputStream inputStream, int length) throws java.sql.SQLException
java.sql.SQLException
public void copyCharacterStream(java.io.Reader inputStream, int length, java.lang.String encoding) throws java.sql.SQLException
java.sql.SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |