Top Description Fields Constructors Methods
org.h2.jdbc

public final Class JdbcBlob

extends JdbcLob
implements Blob
Class Inheritance
All Implemented Interfaces
java.sql.Blob
Imports
java.io.BufferedInputStream, .BufferedOutputStream, .ByteArrayInputStream, .ByteArrayOutputStream, .InputStream, .OutputStream, .PipedInputStream, java.sql.Blob, .SQLException, org.h2.engine.Constants, org.h2.message.DbException, .TraceObject, org.h2.util.IOUtils, .Task, org.h2.value.Value

Represents a BLOB value.

Field Summary

Inherited from org.h2.jdbc.JdbcLob:
connstatevalue

Constructor Summary

AccessConstructor and Description
public
JdbcBlob(JdbcConnection
it belongs to
conn
,
Value
of
value
,
JdbcLob.State
of the LOB
state
,
int
of the trace object
id
)

INTERNAL

Method Summary

Modifier and TypeMethod and Description
public InputStream
getBinaryStream()

Overrides org.h2.jdbc.JdbcLob.getBinaryStream.

Implements java.sql.Blob.getBinaryStream.

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

public InputStream

Returns:

the input stream to read
getBinaryStream
(long
where to start reading
pos
,
long
the number of bytes that will be read
length
)

Implements java.sql.Blob.getBinaryStream.

Returns the input stream, starting from an offset.

public byte[]

Returns:

the bytes, at most length bytes
getBytes
(long
the index, the first byte is at position 1
pos
,
int
the number of bytes
length
)

Implements java.sql.Blob.getBytes.

Returns some bytes of the object.

public long

Returns:

the length
length
()

Implements java.sql.Blob.length.

Returns the length.

public long

Returns:

the position (first byte is at position 1), or -1 for not found
position
(byte[]
the pattern to search
pattern
,
long
the index, the first byte is at position 1
start
)

Implements java.sql.Blob.position.

[Not supported] Searches a pattern and return the position.

public long

Returns:

the position (first byte is at position 1), or -1 for not found
position
(Blob
the pattern to search
blobPattern
,
long
the index, the first byte is at position 1
start
)

Implements java.sql.Blob.position.

[Not supported] Searches a pattern and return the position.

public OutputStream

Returns:

an output stream
setBinaryStream
(long
where to start writing (the first byte is at position 1)
pos
)

Implements java.sql.Blob.setBinaryStream.

Get a writer to update the Blob.

public int

Returns:

the length of the added data
setBytes
(long
where to start writing (the first byte is at position 1)
pos
,
byte[]
the bytes to set
bytes
)

Implements java.sql.Blob.setBytes.

Fills the Blob.

public int

Returns:

how many bytes have been written
setBytes
(long
the write position
pos
,
byte[]
the bytes to set
bytes
,
int
the bytes offset
offset
,
int
the number of bytes to write
len
)

Implements java.sql.Blob.setBytes.

Sets some bytes of the object.

public void
truncate(long
the new length
len
)

Implements java.sql.Blob.truncate.

[Not supported] Truncates the object.

Inherited from org.h2.jdbc.JdbcLob:
checkClosedcheckEditablecheckReadablecompleteWritefreegetCharacterStreamsetCharacterStreamImplsetClobOutputStreamImpltoString

Constructor Detail

JdbcBlobback to summary
public JdbcBlob(JdbcConnection conn, Value value, JdbcLob.State state, int id)

INTERNAL

Parameters
conn:JdbcConnection

it belongs to

value:Value

of

state:JdbcLob.State

of the LOB

id:int

of the trace object

Method Detail

getBinaryStreamback to summary
public InputStream getBinaryStream() throws SQLException

Overrides org.h2.jdbc.JdbcLob.getBinaryStream.

Implements java.sql.Blob.getBinaryStream.

Doc from java.sql.Blob.getBinaryStream.

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

Returns:InputStream

a stream containing the BLOB data

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

Implements java.sql.Blob.getBinaryStream.

Returns the input stream, starting from an offset.

Parameters
pos:long

where to start reading

length:long

the number of bytes that will be read

Returns:InputStream

the input stream to read

Annotations
@Override
Exceptions
SQLException:

Doc from java.sql.Blob.getBinaryStream.

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

getBytesback to summary
public byte[] getBytes(long pos, int length) throws SQLException

Implements java.sql.Blob.getBytes.

Returns some bytes of the object.

Parameters
pos:long

the index, the first byte is at position 1

length:int

the number of bytes

Returns:byte[]

the bytes, at most length bytes

Annotations
@Override
Exceptions
SQLException:

Doc from java.sql.Blob.getBytes.

if there is an error accessing the BLOB value; if pos is less than 1 or length is less than 0

lengthback to summary
public long length() throws SQLException

Implements java.sql.Blob.length.

Returns the length.

Returns:long

the length

Annotations
@Override
Exceptions
SQLException:

Doc from java.sql.Blob.length.

if there is an error accessing the length of the BLOB

positionback to summary
public long position(byte[] pattern, long start) throws SQLException

Implements java.sql.Blob.position.

[Not supported] Searches a pattern and return the position.

Parameters
pattern:byte[]

the pattern to search

start:long

the index, the first byte is at position 1

Returns:long

the position (first byte is at position 1), or -1 for not found

Annotations
@Override
Exceptions
SQLException:

Doc from java.sql.Blob.position.

if there is an error accessing the BLOB or if start is less than 1

positionback to summary
public long position(Blob blobPattern, long start) throws SQLException

Implements java.sql.Blob.position.

[Not supported] Searches a pattern and return the position.

Parameters
blobPattern:Blob

the pattern to search

start:long

the index, the first byte is at position 1

Returns:long

the position (first byte is at position 1), or -1 for not found

Annotations
@Override
Exceptions
SQLException:

Doc from java.sql.Blob.position.

if there is an error accessing the BLOB value or if start is less than 1

setBinaryStreamback to summary
public OutputStream setBinaryStream(long pos) throws SQLException

Implements java.sql.Blob.setBinaryStream.

Get a writer to update the Blob. This is only supported for new, empty Blob objects that were created with Connection.createBlob(). The Blob is created in a separate thread, and the object is only updated when OutputStream.close() is called. The position must be 1, meaning the whole Blob data is set.

Parameters
pos:long

where to start writing (the first byte is at position 1)

Returns:OutputStream

an output stream

Annotations
@Override
Exceptions
SQLException:

Doc from java.sql.Blob.setBinaryStream.

if there is an error accessing the BLOB value or if pos is less than 1

setBytesback to summary
public int setBytes(long pos, byte[] bytes) throws SQLException

Implements java.sql.Blob.setBytes.

Fills the Blob. This is only supported for new, empty Blob objects that were created with Connection.createBlob(). The position must be 1, meaning the whole Blob data is set.

Parameters
pos:long

where to start writing (the first byte is at position 1)

bytes:byte[]

the bytes to set

Returns:int

the length of the added data

Annotations
@Override
Exceptions
SQLException:

Doc from java.sql.Blob.setBytes.

if there is an error accessing the BLOB value or if pos is less than 1

setBytesback to summary
public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException

Implements java.sql.Blob.setBytes.

Sets some bytes of the object.

Parameters
pos:long

the write position

bytes:byte[]

the bytes to set

offset:int

the bytes offset

len:int

the number of bytes to write

Returns:int

how many bytes have been written

Annotations
@Override
Exceptions
SQLException:

Doc from java.sql.Blob.setBytes.

if there is an error accessing the BLOB value or if pos is less than 1

truncateback to summary
public void truncate(long len) throws SQLException

Implements java.sql.Blob.truncate.

[Not supported] Truncates the object.

Parameters
len:long

the new length

Annotations
@Override
Exceptions
SQLException:

Doc from java.sql.Blob.truncate.

if there is an error accessing the BLOB value or if len is less than 0