Class JDBCBlobClient
java.lang.Object
org.hsqldb.jdbc.JDBCBlobClient
- All Implemented Interfaces:
Blob
-
Constructor Summary
ConstructorsConstructorDescriptionJDBCBlobClient(org.hsqldb.SessionInterface session, org.hsqldb.types.BlobDataID blob) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidfree()This method frees theBlobobject and releases the resources that it holds.Retrieves theBLOBvalue designated by thisBlobinstance as a stream.getBinaryStream(long pos, long length) Returns anInputStreamobject that contains a partialBlobvalue, starting with the byte specified by pos, which is length bytes in length.org.hsqldb.types.BlobDataIDgetBlob()byte[]getBytes(long pos, int length) Retrieves all or part of theBLOBvalue that thisBlobobject represents, as an array of bytes.booleanisClosed()longlength()Returns the number of bytes in theBLOBvalue designated by thisBlobobject.longposition(byte[] pattern, long start) Retrieves the byte position at which the specified byte arraypatternbegins within theBLOBvalue that thisBlobobject represents.longRetrieves the byte position in theBLOBvalue designated by thisBlobobject at whichpatternbegins.setBinaryStream(long pos) Retrieves a stream that can be used to write to theBLOBvalue that thisBlobobject represents.intsetBytes(long pos, byte[] bytes) Writes the given array of bytes to theBLOBvalue that thisBlobobject represents, starting at positionpos, and returns the number of bytes written.intsetBytes(long pos, byte[] bytes, int offset, int len) Writes all or part of the givenbytearray to theBLOBvalue that thisBlobobject represents and returns the number of bytes written.voidsetWritable(JDBCResultSet result, int index) voidtruncate(long len) Truncates theBLOBvalue that thisBlobobject represents to belenbytes in length.
-
Constructor Details
-
JDBCBlobClient
public JDBCBlobClient(org.hsqldb.SessionInterface session, org.hsqldb.types.BlobDataID blob)
-
-
Method Details
-
length
Returns the number of bytes in theBLOBvalue designated by thisBlobobject.- Specified by:
lengthin interfaceBlob- Returns:
- length of the
BLOBin bytes - Throws:
SQLException- if there is an error accessing the length of theBLOB
-
getBytes
Retrieves all or part of theBLOBvalue that thisBlobobject represents, as an array of bytes.- Specified by:
getBytesin interfaceBlob- Parameters:
pos- the ordinal position of the first byte in theBLOBvalue to be extracted; the first byte is at position 1length- the number of consecutive bytes to be copied- Returns:
- a byte array containing up to
lengthconsecutive bytes from theBLOBvalue designated by thisBlobobject, starting with the byte at positionpos - Throws:
SQLException- if there is an error accessing theBLOBvalue
-
getBinaryStream
Retrieves theBLOBvalue designated by thisBlobinstance as a stream.- Specified by:
getBinaryStreamin interfaceBlob- Returns:
- a stream containing the
BLOBdata - Throws:
SQLException- if there is an error accessing theBLOBvalue
-
position
Retrieves the byte position at which the specified byte arraypatternbegins within theBLOBvalue that thisBlobobject represents.- Specified by:
positionin interfaceBlob- Parameters:
pattern- the byte array for which to searchstart- the position at which to begin searching; the first position is 1- Returns:
- the position at which the pattern appears, else -1
- Throws:
SQLException- if there is an error accessing theBLOB
-
position
Retrieves the byte position in theBLOBvalue designated by thisBlobobject at whichpatternbegins.- Specified by:
positionin interfaceBlob- Parameters:
pattern- theBlobobject designating theBLOBvalue for which to searchstart- the position in theBLOBvalue at which to begin searching; the first position is 1- Returns:
- the position at which the pattern begins, else -1
- Throws:
SQLException- if there is an error accessing theBLOBvalue
-
setBytes
Writes the given array of bytes to theBLOBvalue that thisBlobobject represents, starting at positionpos, and returns the number of bytes written.- Specified by:
setBytesin interfaceBlob- Parameters:
pos- the position in theBLOBobject at which to start writingbytes- the array of bytes to be written to theBLOBvalue that thisBlobobject represents- Returns:
- the number of bytes written
- Throws:
SQLException- if there is an error accessing theBLOBvalue
-
setBytes
Writes all or part of the givenbytearray to theBLOBvalue that thisBlobobject represents and returns the number of bytes written.- Specified by:
setBytesin interfaceBlob- Parameters:
pos- the position in theBLOBobject at which to start writingbytes- the array of bytes to be written to thisBLOBobjectoffset- the offset into the arraybytesat which to start reading the bytes to be setlen- the number of bytes to be written to theBLOBvalue from the array of bytesbytes- Returns:
- the number of bytes written
- Throws:
SQLException- if there is an error accessing theBLOBvalue
-
setBinaryStream
Retrieves a stream that can be used to write to theBLOBvalue that thisBlobobject represents.- Specified by:
setBinaryStreamin interfaceBlob- Parameters:
pos- the position in theBLOBvalue at which to start writing- Returns:
- a
java.io.OutputStreamobject to which data can be written - Throws:
SQLException- if there is an error accessing theBLOBvalue
-
truncate
Truncates theBLOBvalue that thisBlobobject represents to belenbytes in length.- Specified by:
truncatein interfaceBlob- Parameters:
len- the length, in bytes, to which theBLOBvalue that thisBlobobject represents should be truncated- Throws:
SQLException- if there is an error accessing theBLOBvalue
-
free
This method frees theBlobobject and releases the resources that it holds. The object is invalid once thefreemethod is called.After
freehas been called, any attempt to invoke a method other thanfreewill result in aSQLExceptionbeing thrown. Iffreeis called multiple times, the subsequent calls tofreeare treated as a no-op.- Specified by:
freein interfaceBlob- Throws:
SQLException- if an error occurs releasing the Blob's resources- Since:
- JDK 1.6, HSQLDB 2.0
-
getBinaryStream
Returns anInputStreamobject that contains a partialBlobvalue, starting with the byte specified by pos, which is length bytes in length.- Specified by:
getBinaryStreamin interfaceBlob- Parameters:
pos- the offset to the first byte of the partial value to be retrieved. The first byte in theBlobis at position 1length- the length in bytes of the partial value to be retrieved- Returns:
InputStreamthrough which the partialBlobvalue can be read.- Throws:
SQLException- if pos is less than 1 or if pos is greater than the number of bytes in theBlobor if pos + length is greater than the number of bytes in theBlob- Since:
- JDK 1.6, HSQLDB 2.0
-
isClosed
public boolean isClosed() -
getBlob
public org.hsqldb.types.BlobDataID getBlob() -
setWritable
-
clearUpdates
public void clearUpdates()
-