Interface FbDatabase
- 
- All Superinterfaces:
- java.lang.AutoCloseable,- ExceptionListenable,- FbAttachment
 - All Known Subinterfaces:
- FbWireDatabase
 - All Known Implementing Classes:
- AbstractFbDatabase,- AbstractFbWireDatabase,- JnaDatabase,- V10Database,- V11Database,- V12Database,- V13Database,- V15Database,- V16Database,- V18Database,- V19Database
 
 public interface FbDatabase extends FbAttachment Connection handle to a database.All methods defined in this interface are required to notify all SQLExceptionthrown from the methods defined in this interface, and those exceptions notified by allExceptionListenableimplementations created from them.- Since:
- 3.0
- Author:
- Mark Rotteveel
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddDatabaseListener(DatabaseListener listener)Adds aDatabaseListenerinstance to this database.voidaddWeakDatabaseListener(DatabaseListener listener)Adds aDatabaseListenerinstance to this database using a weak reference.voidcancelEvent(EventHandle eventHandle)Cancels a registered event.voidcancelOperation(int kind)Cancels the current operation.voidcountEvents(EventHandle eventHandle)Counts the events occurred.default FbBlobcreateBlobForInput(FbTransaction transaction, long blobId)Creates a blob for read access to an existing blob on the server.FbBlobcreateBlobForInput(FbTransaction transaction, BlobParameterBuffer blobParameterBuffer, long blobId)Creates a blob for read access to an existing blob on the server.default FbBlobcreateBlobForInput(FbTransaction transaction, BlobConfig blobConfig, long blobId)Creates a blob for read access to an existing blob on the server.default FbBlobcreateBlobForOutput(FbTransaction transaction)Creates a blob for write access to a new blob on the server.FbBlobcreateBlobForOutput(FbTransaction transaction, BlobParameterBuffer blobParameterBuffer)Creates a blob for write access to a new blob on the server.default FbBlobcreateBlobForOutput(FbTransaction transaction, BlobConfig blobConfig)Creates a blob for write access to a new blob on the server.BlobParameterBuffercreateBlobParameterBuffer()Creates a blob parameter buffer that is usable withcreateBlobForInput(FbTransaction, org.firebirdsql.gds.BlobParameterBuffer, long)andcreateBlobForOutput(FbTransaction, org.firebirdsql.gds.BlobParameterBuffer)of this instance.voidcreateDatabase()Creates a new database, connection remains attached to database.EventHandlecreateEventHandle(java.lang.String eventName, EventHandler eventHandler)Creates an event handle for this database type.FbStatementcreateStatement(FbTransaction transaction)Creates a statement associated with a transactionTransactionParameterBuffercreateTransactionParameterBuffer()Creates a transaction parameter buffer that is usable withstartTransaction(org.firebirdsql.gds.TransactionParameterBuffer).voiddropDatabase()Drops (and deletes) the currently attached database.RowDescriptoremptyRowDescriptor()voidexecuteImmediate(java.lang.String statementText, FbTransaction transaction)Performs an execute immediate of a statement.shortgetConnectionDialect()IConnectionPropertiesgetConnectionProperties()shortgetDatabaseDialect()byte[]getDatabaseInfo(byte[] requestItems, int maxBufferLength)Performs a database info request.<T> TgetDatabaseInfo(byte[] requestItems, int bufferLength, InfoProcessor<T> infoProcessor)Request database info.intgetHandle()intgetOdsMajor()intgetOdsMinor()voidqueueEvent(EventHandle eventHandle)Queues a wait for an event.FbTransactionreconnectTransaction(long transactionId)Reconnects a prepared transaction.voidremoveDatabaseListener(DatabaseListener listener)Removes aDatabaseListenerinstance from this database.FbTransactionstartTransaction(TransactionParameterBuffer tpb)Creates and starts a transaction.- 
Methods inherited from interface org.firebirdsql.gds.ng.listeners.ExceptionListenableaddExceptionListener, removeExceptionListener
 - 
Methods inherited from interface org.firebirdsql.gds.ng.FbAttachmentattach, close, forceClose, getDatatypeCoder, getEncoding, getEncodingFactory, getNetworkTimeout, getServerVersion, isAttached, isLockedByCurrentThread, setNetworkTimeout, withLock
 
- 
 
- 
- 
- 
Method Detail- 
createDatabasevoid createDatabase() throws java.sql.SQLExceptionCreates a new database, connection remains attached to database.- Throws:
- java.sql.SQLException
 
 - 
dropDatabasevoid dropDatabase() throws java.sql.SQLExceptionDrops (and deletes) the currently attached database.- Throws:
- java.sql.SQLException
 
 - 
cancelOperationvoid cancelOperation(int kind) throws java.sql.SQLExceptionCancels the current operation.The cancellation types are: - ISCConstants.fb_cancel_disable
- disables execution of fb_cancel_raise requests for the specified attachment. It can be useful when your program is executing critical operations, such as cleanup, for example.
- ISCConstants.fb_cancel_enable
- re-enables delivery of a cancel execution that was previously disabled. The 'cancel' state is effective by default, being initialized when the attachment is created.
- ISCConstants.fb_cancel_raise
- cancels any activity related to the database handle. The effect will be that, as soon as possible, the engine will try to stop the running request and return an exception to the caller
- ISCConstants.fb_cancel_abort
- forcibly close client side of connection. Useful if you need to close a connection urgently. All active transactions will be rolled back by the server. 'Success' is always returned to the application. Use with care!
 - Parameters:
- kind- Cancellation type
- Throws:
- java.sql.SQLException- For errors cancelling, or if the cancel operation is not supported.
 
 - 
startTransactionFbTransaction startTransaction(TransactionParameterBuffer tpb) throws java.sql.SQLException Creates and starts a transaction.- Parameters:
- tpb- TransactionParameterBuffer with the required transaction options
- Returns:
- FbTransaction
- Throws:
- java.sql.SQLException
 
 - 
reconnectTransactionFbTransaction reconnectTransaction(long transactionId) throws java.sql.SQLException Reconnects a prepared transaction.Reconnecting transactions is only allowed for transactions in limbo (prepared, but not committed or rolled back). - Parameters:
- transactionId- The id of the transaction to reconnect.
- Returns:
- FbTransaction
- Throws:
- java.sql.SQLException- For errors reconnecting the transaction
 
 - 
createStatementFbStatement createStatement(FbTransaction transaction) throws java.sql.SQLException Creates a statement associated with a transaction- Parameters:
- transaction- FbTransaction to associate with this statement (can be- null)
- Returns:
- FbStatement
- Throws:
- java.sql.SQLException
 
 - 
createBlobForOutputFbBlob createBlobForOutput(FbTransaction transaction, BlobParameterBuffer blobParameterBuffer) throws java.sql.SQLException Creates a blob for write access to a new blob on the server.The blob is initially closed. - Parameters:
- transaction- transaction associated with the blob
- blobParameterBuffer- blob parameter buffer
- Returns:
- instance of FbBlob
- Throws:
- java.sql.SQLException- if the database is not attached or the transaction is not active
 
 - 
createBlobForOutputdefault FbBlob createBlobForOutput(FbTransaction transaction) throws java.sql.SQLException Creates a blob for write access to a new blob on the server.The blob is initially closed. Equivalent to calling createBlobForOutput(FbTransaction, BlobParameterBuffer)withnullforblobParameterBuffer.- Parameters:
- transaction- transaction associated with the blob
- Returns:
- instance of FbBlob
- Throws:
- java.sql.SQLException- if the database is not attached or the transaction is not active
- Since:
- 5
 
 - 
createBlobForOutputdefault FbBlob createBlobForOutput(FbTransaction transaction, BlobConfig blobConfig) throws java.sql.SQLException Creates a blob for write access to a new blob on the server.The blob is initially closed. - Parameters:
- transaction- transaction associated with the blob
- blobConfig- blob config (cannot be- null)
- Returns:
- instance of FbBlob
- Throws:
- java.sql.SQLException- if the database is not attached or the transaction is not active
- Since:
- 5
 
 - 
createBlobForInputFbBlob createBlobForInput(FbTransaction transaction, BlobParameterBuffer blobParameterBuffer, long blobId) throws java.sql.SQLException Creates a blob for read access to an existing blob on the server.The blob is initially closed. If the server supports inline blobs, a locally cached blob may be returned if an inline blob was received for transactionandblobId, and ifblobParameterBufferisnullor empty (ParameterBuffer.isEmpty()).- Parameters:
- transaction- transaction associated with the blob
- blobParameterBuffer- blob parameter buffer
- blobId- id of the blob
- Returns:
- instance of FbBlob
- Throws:
- java.sql.SQLException- if the database is not attached or the transaction is not active
 
 - 
createBlobForInputdefault FbBlob createBlobForInput(FbTransaction transaction, long blobId) throws java.sql.SQLException Creates a blob for read access to an existing blob on the server.The blob is initially closed. Equivalent to calling createBlobForInput(FbTransaction, BlobParameterBuffer, long)withnullforblobParameterBuffer.- Parameters:
- transaction- transaction associated with the blob
- blobId- id of the blob
- Returns:
- instance of FbBlob
- Throws:
- java.sql.SQLException- if the database is not attached or the transaction is not active
- Since:
- 5
 
 - 
createBlobForInputdefault FbBlob createBlobForInput(FbTransaction transaction, BlobConfig blobConfig, long blobId) throws java.sql.SQLException Creates a blob for read access to an existing blob on the server.The blob is initially closed. - Parameters:
- transaction- transaction associated with the blob
- blobConfig- blob config (cannot be- null)
- blobId- handle id of the blob
- Returns:
- instance of FbBlob
- Throws:
- java.sql.SQLException- if the database is not attached or the transaction is not active
- Since:
- 5
 
 - 
createBlobParameterBufferBlobParameterBuffer createBlobParameterBuffer() Creates a blob parameter buffer that is usable withcreateBlobForInput(FbTransaction, org.firebirdsql.gds.BlobParameterBuffer, long)andcreateBlobForOutput(FbTransaction, org.firebirdsql.gds.BlobParameterBuffer)of this instance.- Returns:
- A blob parameter buffer.
 
 - 
createTransactionParameterBufferTransactionParameterBuffer createTransactionParameterBuffer() Creates a transaction parameter buffer that is usable withstartTransaction(org.firebirdsql.gds.TransactionParameterBuffer).- Returns:
- A transaction parameter buffer
 
 - 
getDatabaseInfo<T> T getDatabaseInfo(byte[] requestItems, int bufferLength, InfoProcessor<T> infoProcessor) throws java.sql.SQLExceptionRequest database info.- Parameters:
- requestItems- Array of info items to request
- bufferLength- Response buffer length to use
- infoProcessor- Implementation of- InfoProcessorto transform the info response
- Returns:
- Transformed info response of type T
- Throws:
- java.sql.SQLException- For errors retrieving or transforming the response.
 
 - 
getDatabaseInfobyte[] getDatabaseInfo(byte[] requestItems, int maxBufferLength) throws java.sql.SQLExceptionPerforms a database info request.- Parameters:
- requestItems- Information items to request
- maxBufferLength- Maximum response buffer length to use
- Returns:
- The response buffer (note: length is the actual length of the response, not maxBufferLength
- Throws:
- java.sql.SQLException- For errors retrieving the information.
 
 - 
executeImmediatevoid executeImmediate(java.lang.String statementText, FbTransaction transaction) throws java.sql.SQLExceptionPerforms an execute immediate of a statement.A call to this method is the equivalent of a isc_dsql_execute_immediate()without parameters.- Parameters:
- statementText- Statement text
- transaction- Transaction (- nullonly allowed if database is not attached!)
- Throws:
- java.sql.SQLException- For errors executing the statement, or if- transactionis- nullwhen the database is attached or not- nullwhen the database is not attached
 
 - 
getDatabaseDialectshort getDatabaseDialect() - Returns:
- The database dialect
 
 - 
getConnectionDialectshort getConnectionDialect() - Returns:
- The client connection dialect
 
 - 
getHandleint getHandle() - Specified by:
- getHandlein interface- FbAttachment
- Returns:
- The database handle value
 
 - 
getOdsMajorint getOdsMajor() - Returns:
- ODS major version
 
 - 
getOdsMinorint getOdsMinor() - Returns:
- ODS minor version
 
 - 
addDatabaseListenervoid addDatabaseListener(DatabaseListener listener) Adds aDatabaseListenerinstance to this database.- Parameters:
- listener- Database listener
 
 - 
addWeakDatabaseListenervoid addWeakDatabaseListener(DatabaseListener listener) Adds aDatabaseListenerinstance to this database using a weak reference.If the listener is already strongly referenced, this call will be ignored - Parameters:
- listener- Database listener
 
 - 
removeDatabaseListenervoid removeDatabaseListener(DatabaseListener listener) Removes aDatabaseListenerinstance from this database.- Parameters:
- listener- Database Listener
 
 - 
createEventHandleEventHandle createEventHandle(java.lang.String eventName, EventHandler eventHandler) throws java.sql.SQLException Creates an event handle for this database type.The returned event handle can be used with queueEvent(org.firebirdsql.gds.EventHandle).- Parameters:
- eventName- Name of the event
- eventHandler- The event handler to call when the event occurred
- Returns:
- A suitable event handle instance
- Throws:
- java.sql.SQLException- For errors creating the event handle
 
 - 
countEventsvoid countEvents(EventHandle eventHandle) throws java.sql.SQLException Counts the events occurred.- Parameters:
- eventHandle- The event handle
- Throws:
- java.sql.SQLException- When the count can not be done (as - for example - the event handle is of the wrong type)
 
 - 
queueEventvoid queueEvent(EventHandle eventHandle) throws java.sql.SQLException Queues a wait for an event.- Parameters:
- eventHandle- The event handle (created using- createEventHandle(String, EventHandler)of this instance).
- Throws:
- java.sql.SQLException- For errors establishing the asynchronous channel, or for queuing the event.
 
 - 
cancelEventvoid cancelEvent(EventHandle eventHandle) throws java.sql.SQLException Cancels a registered event.After cancellation, the event handle should be considered unusable. Before queueing a new event, an new handle needs to be created. - Parameters:
- eventHandle- The event handle to cancel
- Throws:
- java.sql.SQLException- For errors cancelling the event
 
 - 
getConnectionPropertiesIConnectionProperties getConnectionProperties() - Returns:
- An immutable copy of the connection properties of this database
 
 - 
emptyRowDescriptorRowDescriptor emptyRowDescriptor() - Returns:
- A potentially cached empty row descriptor for this database.
 
 
- 
 
-