Package org.firebirdsql.jdbc
Class FBBlob
- java.lang.Object
- 
- org.firebirdsql.jdbc.FBBlob
 
- 
- All Implemented Interfaces:
- java.sql.Blob,- TransactionListener,- FirebirdBlob
 
 public final class FBBlob extends java.lang.Object implements FirebirdBlob, TransactionListener Firebird implementation ofBlob.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classFBBlob.ConfigStandard configuration for blobs.- 
Nested classes/interfaces inherited from interface org.firebirdsql.jdbc.FirebirdBlobFirebirdBlob.BlobInputStream, FirebirdBlob.BlobOutputStream
 
- 
 - 
Constructor SummaryConstructors Constructor Description FBBlob(GDSHelper c)Deprecated.will be removed in Jaybird 6, useFBBlob(GDSHelper, FBObjectListener.BlobListener, Config)FBBlob(GDSHelper c, long blobId)Deprecated.will be removed in Jaybird 6, useFBBlob(GDSHelper, long, FBObjectListener.BlobListener, Config)FBBlob(GDSHelper c, long blobId, FBObjectListener.BlobListener blobListener)Deprecated.will be removed in Jaybird 6, useFBBlob(GDSHelper, long, FBObjectListener.BlobListener, Config)FBBlob(GDSHelper c, long blobId, FBObjectListener.BlobListener blobListener, FBBlob.Config config)Create instance of this class to access existing Blob.FBBlob(GDSHelper c, FBObjectListener.BlobListener blobListener)Deprecated.will be removed in Jaybird 6, useFBBlob(GDSHelper, FBObjectListener.BlobListener, Config)FBBlob(GDSHelper c, FBObjectListener.BlobListener blobListener, FBBlob.Config config)Create new Blob instance.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopyBytes(byte[] bytes, int pos, int len)voidcopyCharacterStream(java.io.Reader reader)Copy data from a character stream into this Blob.voidcopyCharacterStream(java.io.Reader reader, long length)Copy data from a character stream into this Blob.voidcopyCharacterStream(java.io.Reader reader, long length, Encoding encoding)Copy data from a character stream into this Blob.voidcopyCharacterStream(java.io.Reader reader, Encoding encoding)Copy data from a character stream into this Blob.voidcopyStream(java.io.InputStream inputStream)Copy the contents of anInputStreaminto this Blob.voidcopyStream(java.io.InputStream inputStream, long length)Copy the contents of anInputStreaminto this Blob.static FBBlob.ConfigcreateConfig(int subType, boolean useStreamBlob, int blobBufferSize, DatatypeCoder datatypeCoder)Create a blob configuration.static FBBlob.ConfigcreateConfig(int subType, DatabaseConnectionProperties connectionProperties, DatatypeCoder datatypeCoder)Creates a blob configuration from a subtype and connection properties and datatype coder.static FBBlob.ConfigcreateConfig(FieldDescriptor fieldDescriptor, DatabaseConnectionProperties connectionProperties)Creates a blob configuration from a field descriptor and connection properties.FirebirdBlobdetach()Detach this blob.voidfree()java.io.InputStreamgetBinaryStream()java.io.InputStreamgetBinaryStream(long pos, long length)longgetBlobId()Get the identifier for thisBlobbyte[]getBytes(long pos, int length)byte[]getInfo(byte[] items, int bufferLength)Get information about this Blob.booleanisSegmented()Check if blob is segmented.longlength()longposition(byte[] pattern, long start)longposition(java.sql.Blob pattern, long start)java.io.OutputStreamsetBinaryStream(long pos)intsetBytes(long pos, byte[] bytes)intsetBytes(long pos, byte[] bytes, int offset, int len)voidtransactionStateChanged(FbTransaction transaction, TransactionState newState, TransactionState previousState)Signals that the transaction state changed.voidtruncate(long len)
 
- 
- 
- 
Constructor Detail- 
FBBlob@Deprecated public FBBlob(GDSHelper c, FBObjectListener.BlobListener blobListener) Deprecated.will be removed in Jaybird 6, useFBBlob(GDSHelper, FBObjectListener.BlobListener, Config)Create new Blob instance. This constructor creates new fresh Blob, only writing to the Blob is allowed.- Parameters:
- c- connection that will be used to write data to blob
- blobListener- Blob listener instance
 
 - 
FBBlobpublic FBBlob(GDSHelper c, FBObjectListener.BlobListener blobListener, FBBlob.Config config) Create new Blob instance. This constructor creates new fresh Blob, only writing to the Blob is allowed.- Parameters:
- c- connection that will be used to write data to blob
- blobListener- Blob listener instance
- config- blob configuration (- nullallowed in Jaybird 5, will be disallowed in Jaybird 6)
- Since:
- 5
 
 - 
FBBlob@Deprecated public FBBlob(GDSHelper c) Deprecated.will be removed in Jaybird 6, useFBBlob(GDSHelper, FBObjectListener.BlobListener, Config)Create new Blob instance. This constructor creates new fresh Blob, only writing to the Blob is allowed.- Parameters:
- c- connection that will be used to write data to blob.
 
 - 
FBBlob@Deprecated public FBBlob(GDSHelper c, long blobId, FBObjectListener.BlobListener blobListener) Deprecated.will be removed in Jaybird 6, useFBBlob(GDSHelper, long, FBObjectListener.BlobListener, Config)Create instance of this class to access existing Blob.- Parameters:
- c- connection that will be used to access Blob.
- blobId- ID of the Blob.
- blobListener- blob listener instance
 
 - 
FBBlobpublic FBBlob(GDSHelper c, long blobId, FBObjectListener.BlobListener blobListener, FBBlob.Config config) Create instance of this class to access existing Blob.- Parameters:
- c- connection that will be used to access Blob.
- blobId- ID of the Blob.
- blobListener- blob listener instance
- config- blob configuration (- nullallowed in Jaybird 5, will be disallowed in Jaybird 6)
- Since:
- 5
 
 - 
FBBlob@Deprecated public FBBlob(GDSHelper c, long blobId) Deprecated.will be removed in Jaybird 6, useFBBlob(GDSHelper, long, FBObjectListener.BlobListener, Config)Create instance of this class to access existing Blob.- Parameters:
- c- connection that will be used to access Blob.
- blobId- ID of the Blob.
 
 
- 
 - 
Method Detail- 
freepublic void free() throws java.sql.SQLException- Specified by:
- freein interface- java.sql.Blob
- Throws:
- java.sql.SQLException
 
 - 
getBinaryStreampublic java.io.InputStream getBinaryStream(long pos, long length) throws java.sql.SQLException- Specified by:
- getBinaryStreamin interface- java.sql.Blob
- Throws:
- java.sql.SQLException
 
 - 
getInfopublic byte[] getInfo(byte[] items, int bufferLength) throws java.sql.SQLExceptionGet information about this Blob. This method should be considered as temporary because it provides access to low-level API. More information on how to use the API can be found in "API Guide".- Parameters:
- items- items in which we are interested
- bufferLength- buffer where information will be stored
- Returns:
- array of bytes containing information about this Blob
- Throws:
- java.sql.SQLException- if something went wrong
 
 - 
lengthpublic long length() throws java.sql.SQLException- Specified by:
- lengthin interface- java.sql.Blob
- Throws:
- java.sql.SQLException
 
 - 
isSegmentedpublic boolean isSegmented() throws java.sql.SQLExceptionDescription copied from interface:FirebirdBlobCheck if blob is segmented. If Blob is segmented, you cannot useFirebirdBlob.BlobInputStream.seek(int)method.- Specified by:
- isSegmentedin interface- FirebirdBlob
- Returns:
- trueif this blob is segmented, otherwise- false
- Throws:
- java.sql.SQLException
 
 - 
detachpublic FirebirdBlob detach() throws java.sql.SQLException Description copied from interface:FirebirdBlobDetach this blob. This method creates new instance of the same blob database object that is not under result set control. When result set is closed, all associated resources are also released, including open blob streams. This method creates a new instance of blob object with the same blob ID that can be used even when result set is closed.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. - Specified by:
- detachin interface- FirebirdBlob
- Returns:
- instance of FirebirdBlobthat is not under result set control.
- Throws:
- java.sql.SQLException- if Blob cannot be detached.
 
 - 
getBytespublic byte[] getBytes(long pos, int length) throws java.sql.SQLException- Specified by:
- getBytesin interface- java.sql.Blob
- Throws:
- java.sql.SQLException
 
 - 
getBinaryStreampublic java.io.InputStream getBinaryStream() throws java.sql.SQLException- Specified by:
- getBinaryStreamin interface- java.sql.Blob
- Throws:
- java.sql.SQLException
 
 - 
positionpublic long position(byte[] pattern, long start) throws java.sql.SQLException- Specified by:
- positionin interface- java.sql.Blob
- Throws:
- java.sql.SQLException
 
 - 
positionpublic long position(java.sql.Blob pattern, long start) throws java.sql.SQLException- Specified by:
- positionin interface- java.sql.Blob
- Throws:
- java.sql.SQLException
 
 - 
truncatepublic void truncate(long len) throws java.sql.SQLException- Specified by:
- truncatein interface- java.sql.Blob
- Throws:
- java.sql.SQLException
 
 - 
setBytespublic int setBytes(long pos, byte[] bytes) throws java.sql.SQLException- Specified by:
- setBytesin interface- java.sql.Blob
- Throws:
- java.sql.SQLException
 
 - 
setBytespublic int setBytes(long pos, byte[] bytes, int offset, int len) throws java.sql.SQLException- Specified by:
- setBytesin interface- java.sql.Blob
- Throws:
- java.sql.SQLException
 
 - 
setBinaryStreampublic java.io.OutputStream setBinaryStream(long pos) throws java.sql.SQLException- Specified by:
- setBinaryStreamin interface- java.sql.Blob
- Throws:
- java.sql.SQLException
 
 - 
getBlobIdpublic long getBlobId() throws java.sql.SQLExceptionGet the identifier for thisBlob- Returns:
- This Blob's identifier
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
copyBytespublic void copyBytes(byte[] bytes, int pos, int len) throws java.sql.SQLException- Throws:
- java.sql.SQLException
 
 - 
copyStreampublic void copyStream(java.io.InputStream inputStream, long length) throws java.sql.SQLExceptionCopy the contents of anInputStreaminto this Blob.Calling with length -1is equivalent to callingcopyStream(InputStream), and will copy the whole stream.- Parameters:
- inputStream- the stream from which data will be copied
- length- The maximum number of bytes to read from the InputStream,- -1to read whole stream
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
copyStreampublic void copyStream(java.io.InputStream inputStream) throws java.sql.SQLExceptionCopy the contents of anInputStreaminto this Blob. Unlike thecopyStream(InputStream, long)method, this one copies bytes until the EOF is reached.- Parameters:
- inputStream- the stream from which data will be copied
- Throws:
- java.sql.SQLException- if a database access error occurs
 
 - 
copyCharacterStreampublic void copyCharacterStream(java.io.Reader reader, long length, Encoding encoding) throws java.sql.SQLExceptionCopy data from a character stream into this Blob.Calling with length -1is equivalent to callingcopyCharacterStream(Reader, Encoding).- Parameters:
- reader- the source of data to copy
- length- The maximum number of bytes to copy, or- -1to read the whole stream
- encoding- The encoding used in the character stream
- Throws:
- java.sql.SQLException
- See Also:
- copyCharacterStream(Reader, long)
 
 - 
copyCharacterStreampublic void copyCharacterStream(java.io.Reader reader, long length) throws java.sql.SQLExceptionCopy data from a character stream into this Blob. This method uses the encoding from the blob config (field character set for subtype TEXT, if known, otherwise connection character set).Calling with length -1is equivalent to callingcopyCharacterStream(Reader).- Parameters:
- reader- the source of data to copy
- length- The maximum number of bytes to copy, or- -1to read the whole stream
- Throws:
- java.sql.SQLException
- Since:
- 5
 
 - 
copyCharacterStreampublic void copyCharacterStream(java.io.Reader reader, Encoding encoding) throws java.sql.SQLExceptionCopy data from a character stream into this Blob. Unlike thecopyCharacterStream(Reader, long, Encoding)method, this one copies bytes until the EOF is reached.- Parameters:
- reader- the source of data to copy
- encoding- The encoding used in the character stream
- Throws:
- java.sql.SQLException
- See Also:
- copyCharacterStream(Reader)
 
 - 
copyCharacterStreampublic void copyCharacterStream(java.io.Reader reader) throws java.sql.SQLExceptionCopy data from a character stream into this Blob. Unlike thecopyCharacterStream(Reader, long)method, this one copies bytes until the EOF is reached. This method uses the encoding from the blob config (field character set for subtype TEXT, if known, otherwise connection character set).- Parameters:
- reader- the source of data to copy
- Throws:
- java.sql.SQLException
- Since:
- 5
 
 - 
transactionStateChangedpublic void transactionStateChanged(FbTransaction transaction, TransactionState newState, TransactionState previousState) Description copied from interface:TransactionListenerSignals that the transaction state changed.- Specified by:
- transactionStateChangedin interface- TransactionListener
- Parameters:
- transaction-- FbTransactionthat changed state
 
 - 
createConfig@InternalApi public static FBBlob.Config createConfig(FieldDescriptor fieldDescriptor, DatabaseConnectionProperties connectionProperties) Creates a blob configuration from a field descriptor and connection properties.- Parameters:
- fieldDescriptor- field descriptor
- connectionProperties- connection properties
- Returns:
- field based blob configuration
- Since:
- 5
 
 - 
createConfig@InternalApi public static FBBlob.Config createConfig(int subType, DatabaseConnectionProperties connectionProperties, DatatypeCoder datatypeCoder) Creates a blob configuration from a subtype and connection properties and datatype coder.- Parameters:
- subType- blob subtype (e.g.- ISCConstants.BLOB_SUB_TYPE_BINARYor- ISCConstants.BLOB_SUB_TYPE_TEXT)
- connectionProperties- connection properties
- datatypeCoder- data type coder for the connection character set
- Returns:
- field based blob configuration
- Since:
- 5
 
 - 
createConfig@InternalApi public static FBBlob.Config createConfig(int subType, boolean useStreamBlob, int blobBufferSize, DatatypeCoder datatypeCoder) Create a blob configuration.- Parameters:
- subType- blob subtype (e.g.- ISCConstants.BLOB_SUB_TYPE_BINARYor- ISCConstants.BLOB_SUB_TYPE_TEXT)
- useStreamBlob-- trueuse stream blob,- falseuse segmented blob
- blobBufferSize- blob buffer size
- datatypeCoder- data type coder for the connection character set
- Returns:
- generic blob configuration
- Since:
- 5
 
 
- 
 
-