Class BlobImpl
- java.lang.Object
-
- org.datanucleus.store.rdbms.mapping.column.BlobImpl
-
- All Implemented Interfaces:
java.sql.Blob
public class BlobImpl extends java.lang.Object implements java.sql.Blob
The representation (mapping) in the Java programming language of an SQL
BLOB
value. An SQLBLOB
is a built-in type that stores a Binary Large Object as a column value in a row of a database table. The driver implementsBlob
using an SQLlocator(BLOB)
, which means that aBlob
object contains a logical pointer to the SQLBLOB
data rather than the data itself. ABlob
object is valid for the duration of the transaction in which is was created.Methods in the interfaces
ResultSet
,CallableStatement
, andPreparedStatement
, such asgetBlob
andsetBlob
allow a programmer to access an SQLBLOB
value. TheBlob
interface provides methods for getting the length of an SQLBLOB
(Binary Large Object) value, for materializing aBLOB
value on the client, and for determining the position of a pattern of bytes within aBLOB
value.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
free()
Free the Blob object and releases the resources that it holds.java.io.InputStream
getBinaryStream()
java.io.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)
java.lang.Object
getObject()
Accessor for the Object.long
length()
long
position(byte[] pattern, long start)
long
position(java.sql.Blob pattern, long start)
java.io.OutputStream
setBinaryStream(long value)
int
setBytes(long value, byte[] bytes)
int
setBytes(long value, byte[] bytes, int pos, int length)
void
truncate(long value)
-
-
-
Constructor Detail
-
BlobImpl
public BlobImpl(java.lang.Object obj) throws java.io.IOException
Constructor taking a serialised object.- Parameters:
obj
- The serialised object.- Throws:
java.io.IOException
- if an error occurs
-
BlobImpl
public BlobImpl(byte[] bytes)
Constructor taking a byte array.- Parameters:
bytes
- The byte array
-
BlobImpl
public BlobImpl(java.io.InputStream stream)
Constructor taking an InputStream.- Parameters:
stream
- The InputStream
-
-
Method Detail
-
getObject
public java.lang.Object getObject() throws java.sql.SQLException
Accessor for the Object.- Returns:
- The object.
- Throws:
java.sql.SQLException
- if an error occurs
-
length
public long length() throws java.sql.SQLException
- Specified by:
length
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
getBytes
public byte[] getBytes(long pos, int length) throws java.sql.SQLException
- Specified by:
getBytes
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
setBytes
public int setBytes(long value, byte[] bytes, int pos, int length) throws java.sql.SQLException
- Specified by:
setBytes
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
truncate
public void truncate(long value) throws java.sql.SQLException
- Specified by:
truncate
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
setBytes
public int setBytes(long value, byte[] bytes) throws java.sql.SQLException
- Specified by:
setBytes
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
getBinaryStream
public java.io.InputStream getBinaryStream() throws java.sql.SQLException
- Specified by:
getBinaryStream
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
getBinaryStream
public java.io.InputStream getBinaryStream(long pos, long length) throws java.sql.SQLException
Returns an InputStream object that contains a partial Blob value, starting with the byte specified by pos, which is length bytes in length.- Specified by:
getBinaryStream
in interfacejava.sql.Blob
- Parameters:
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 retrieved- Throws:
java.sql.SQLException
-
setBinaryStream
public java.io.OutputStream setBinaryStream(long value) throws java.sql.SQLException
- Specified by:
setBinaryStream
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
free
public void free() throws java.sql.SQLException
Free the Blob object and releases the resources that it holds. The object is invalid once the free method is called.- Specified by:
free
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
- if an error occurs
-
position
public long position(byte[] pattern, long start) throws java.sql.SQLException
- Specified by:
position
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
position
public long position(java.sql.Blob pattern, long start) throws java.sql.SQLException
- Specified by:
position
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
-