Top Description Fields Constructors Methods
org.hsqldb.jdbc

public Class JDBCBlobClient

extends Object
implements Blob
Class Inheritance
All Implemented Interfaces
java.sql.Blob, java.lang.AutoCloseable
Imports
java.io.InputStream, .OutputStream, java.sql.Blob, .SQLException, org.hsqldb.HsqlException, .SessionInterface, org.hsqldb.error.ErrorCode, org.hsqldb.types.BlobDataID, .BlobInputStream

A wrapper for HSQLDB BlobData objects. Instances of this class are returned by calls to ResultSet methods.
Author
Fred Toussi (fredt@users dot sourceforge.net)
Since
JDK 1.2, HSQLDB 2.0
Version
2.7.4

Field Summary

Modifier and TypeField and Description
pack-priv BlobDataID
pack-priv int
private boolean
private boolean
pack-priv BlobDataID
pack-priv JDBCResultSet
pack-priv SessionInterface

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
public synchronized void
public synchronized void
free()

Implements java.sql.Blob.free.

This method frees the Blob object and releases the resources that it holds.

public synchronized InputStream

Returns:

a stream containing the BLOB data
getBinaryStream
()

Implements java.sql.Blob.getBinaryStream.

Retrieves the BLOB value designated by this Blob instance as a stream.

public synchronized InputStream

Returns:

InputStream through which the partial Blob value can be read.
getBinaryStream
(long
the offset to the first byte of the partial value to be retrieved. The first byte in the Blob is at position 1
pos
,
long
the length in bytes of the partial value to be retrieved
length
)

Implements java.sql.Blob.getBinaryStream.

Returns an InputStream object that contains a partial Blob value, starting with the byte specified by pos, which is length bytes in length.

public BlobDataID
public synchronized byte[]

Returns:

a byte array containing up to length consecutive bytes from the BLOB value designated by this Blob object, starting with the byte at position pos
getBytes
(long
the ordinal position of the first byte in the BLOB value to be extracted; the first byte is at position 1
pos
,
int
the number of consecutive bytes to be copied
length
)

Implements java.sql.Blob.getBytes.

Retrieves all or part of the BLOB value that this Blob object represents, as an array of bytes.

public boolean
pack-priv static boolean
isInLimits(long fullLength, long pos, long len)

public synchronized long

Returns:

length of the BLOB in bytes
length
()

Implements java.sql.Blob.length.

Returns the number of bytes in the BLOB value designated by this Blob object.

public synchronized long

Returns:

the position at which the pattern appears, else -1
position
(byte[]
the byte array for which to search
pattern
,
long
the position at which to begin searching; the first position is 1
start
)

Implements java.sql.Blob.position.

Retrieves the byte position at which the specified byte array pattern begins within the BLOB value that this Blob object represents.

public synchronized long

Returns:

the position at which the pattern begins, else -1
position
(Blob
the Blob object designating the BLOB value for which to search
pattern
,
long
the position in the BLOB value at which to begin searching; the first position is 1
start
)

Implements java.sql.Blob.position.

Retrieves the byte position in the BLOB value designated by this Blob object at which pattern begins.

public synchronized OutputStream

Returns:

a java.io.OutputStream object to which data can be written
setBinaryStream
(long
the position in the BLOB value at which to start writing
pos
)

Implements java.sql.Blob.setBinaryStream.

Retrieves a stream that can be used to write to the BLOB value that this Blob object represents.

public synchronized int

Returns:

the number of bytes written
setBytes
(long
the position in the BLOB object at which to start writing
pos
,
byte[]
the array of bytes to be written to the BLOB value that this Blob object represents
bytes
)

Implements java.sql.Blob.setBytes.

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 synchronized int

Returns:

the number of bytes written
setBytes
(long
the position in the BLOB object at which to start writing
pos
,
byte[]
the array of bytes to be written to this BLOB object
bytes
,
int
the offset into the array bytes at which to start reading the bytes to be set
offset
,
int
the number of bytes to be written to the BLOB value from the array of bytes bytes
len
)

Implements java.sql.Blob.setBytes.

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.

public synchronized void
setWritable(JDBCResultSet result, int index)

private void
public synchronized void
truncate(long
the length, in bytes, to which the BLOB value that this Blob object represents should be truncated
len
)

Implements java.sql.Blob.truncate.

Truncates the BLOB value that this Blob object represents to be len bytes in length.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blobback to summary
pack-priv BlobDataID blob
colIndexback to summary
pack-priv int colIndex
isClosedback to summary
private boolean isClosed
isWritableback to summary
private boolean isWritable
originalBlobback to summary
pack-priv BlobDataID originalBlob
resultSetback to summary
pack-priv JDBCResultSet resultSet
sessionback to summary
pack-priv SessionInterface session

Constructor Detail

JDBCBlobClientback to summary
public JDBCBlobClient(SessionInterface session, BlobDataID blob)

Method Detail

checkClosedback to summary
private void checkClosed() throws SQLException
clearUpdatesback to summary
public synchronized void clearUpdates()
freeback to summary
public synchronized void free() throws SQLException

Implements java.sql.Blob.free.

This method frees the Blob object and releases the resources that it holds. The object is invalid once the free method is called.

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.

Exceptions
SQLException:
if an error occurs releasing the Blob's resources
Since
JDK 1.6, HSQLDB 2.0
getBinaryStreamback to summary
public synchronized InputStream getBinaryStream() throws SQLException

Implements java.sql.Blob.getBinaryStream.

Retrieves the BLOB value designated by this Blob instance as a stream.

Returns:InputStream

a stream containing the BLOB data

Exceptions
SQLException:
if there is an error accessing the BLOB value
getBinaryStreamback to summary
public synchronized InputStream getBinaryStream(long pos, long length) throws SQLException

Implements java.sql.Blob.getBinaryStream.

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:long

the offset to the first byte of the partial value to be retrieved. The first byte in the Blob is at position 1

length:long

the length in bytes of the partial value to be retrieved

Returns:InputStream

InputStream through which the partial Blob value can be read.

Exceptions
SQLException:
if pos is less than 1 or if pos is greater than the number of bytes in the Blob or if pos + length is greater than the number of bytes in the Blob
Since
JDK 1.6, HSQLDB 2.0
getBlobback to summary
public BlobDataID getBlob()
getBytesback to summary
public synchronized byte[] getBytes(long pos, int length) throws SQLException

Implements java.sql.Blob.getBytes.

Retrieves all or part of the BLOB value that this Blob object represents, as an array of bytes.

Parameters
pos:long

the ordinal position of the first byte in the BLOB value to be extracted; the first byte is at position 1

length:int

the number of consecutive bytes to be copied

Returns:byte[]

a byte array containing up to length consecutive bytes from the BLOB value designated by this Blob object, starting with the byte at position pos

Exceptions
SQLException:
if there is an error accessing the BLOB value
isClosedback to summary
public boolean isClosed()
isInLimitsback to summary
pack-priv static boolean isInLimits(long fullLength, long pos, long len)
lengthback to summary
public synchronized long length() throws SQLException

Implements java.sql.Blob.length.

Returns the number of bytes in the BLOB value designated by this Blob object.

Returns:long

length of the BLOB in bytes

Exceptions
SQLException:
if there is an error accessing the length of the BLOB
positionback to summary
public synchronized long position(byte[] pattern, long start) throws SQLException

Implements java.sql.Blob.position.

Retrieves the byte position at which the specified byte array pattern begins within the BLOB value that this Blob object represents.

Parameters
pattern:byte[]

the byte array for which to search

start:long

the position at which to begin searching; the first position is 1

Returns:long

the position at which the pattern appears, else -1

Exceptions
SQLException:
if there is an error accessing the BLOB
positionback to summary
public synchronized long position(Blob pattern, long start) throws SQLException

Implements java.sql.Blob.position.

Retrieves the byte position in the BLOB value designated by this Blob object at which pattern begins.

Parameters
pattern:Blob

the Blob object designating the BLOB value for which to search

start:long

the position in the BLOB value at which to begin searching; the first position is 1

Returns:long

the position at which the pattern begins, else -1

Exceptions
SQLException:
if there is an error accessing the BLOB value
setBinaryStreamback to summary
public synchronized OutputStream setBinaryStream(long pos) throws SQLException

Implements java.sql.Blob.setBinaryStream.

Retrieves a stream that can be used to write to the BLOB value that this Blob object represents.

Parameters
pos:long

the position in the BLOB value at which to start writing

Returns:OutputStream

a java.io.OutputStream object to which data can be written

Exceptions
SQLException:
if there is an error accessing the BLOB value
setBytesback to summary
public synchronized int setBytes(long pos, byte[] bytes) throws SQLException

Implements java.sql.Blob.setBytes.

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:long

the position in the BLOB object at which to start writing

bytes:byte[]

the array of bytes to be written to the BLOB value that this Blob object represents

Returns:int

the number of bytes written

Exceptions
SQLException:
if there is an error accessing the BLOB value
setBytesback to summary
public synchronized int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException

Implements java.sql.Blob.setBytes.

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.

Parameters
pos:long

the position in the BLOB object at which to start writing

bytes:byte[]

the array of bytes to be written to this BLOB object

offset:int

the offset into the array bytes at which to start reading the bytes to be set

len:int

the number of bytes to be written to the BLOB value from the array of bytes bytes

Returns:int

the number of bytes written

Exceptions
SQLException:
if there is an error accessing the BLOB value
setWritableback to summary
public synchronized void setWritable(JDBCResultSet result, int index)
startUpdateback to summary
private void startUpdate() throws SQLException
truncateback to summary
public synchronized void truncate(long len) throws SQLException

Implements java.sql.Blob.truncate.

Truncates the BLOB value that this Blob object represents to be len bytes in length.

Parameters
len:long

the length, in bytes, to which the BLOB value that this Blob object represents should be truncated

Exceptions
SQLException:
if there is an error accessing the BLOB value