Class AbstractFbDatabase<T extends AbstractConnection<IConnectionProperties,? extends FbDatabase>>
- All Implemented Interfaces:
AutoCloseable,FbAttachment,FbDatabase,ExceptionListenable,TransactionListener
- Direct Known Subclasses:
AbstractFbWireDatabase
FbDatabase with behavior common to the various
implementations.- Since:
- 3.0
- Author:
- Mark Rotteveel
-
Field Summary
FieldsFields inherited from class org.firebirdsql.gds.ng.AbstractFbAttachment
connection, exceptionListenerDispatcher -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractFbDatabase(T connection, DatatypeCoder datatypeCoder) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddDatabaseListener(DatabaseListener listener) Adds aDatabaseListenerinstance to this database.final voidaddWeakDatabaseListener(DatabaseListener listener) Adds aDatabaseListenerinstance to this database using a weak reference.final voidclose()Detaches and closes the connection.Creates a blob parameter buffer that is usable withFbDatabase.createBlobForInput(FbTransaction, org.firebirdsql.gds.BlobParameterBuffer, long)andFbDatabase.createBlobForOutput(FbTransaction, org.firebirdsql.gds.BlobParameterBuffer)of this instance.Creates a transaction parameter buffer that is usable withFbDatabase.startTransaction(org.firebirdsql.gds.TransactionParameterBuffer).final RowDescriptorfinal intfinal shortfinal shortfinal <R> RgetDatabaseInfo(byte[] requestItems, int bufferLength, InfoProcessor<R> infoProcessor) Request database info.protected InfoProcessor<FbDatabase>final WarningMessageCallbackprotected byte[]final intfinal intfinal OdsVersionfinal byte[]final byte[]protected byte[]getTransactionIdBuffer(long transactionId) Encodes the transactionId for use inisc_reconnect_transaction/op_reconnect.protected abstract voidActual implementation of database detach.final voidremoveDatabaseListener(DatabaseListener listener) Removes aDatabaseListenerinstance from this database.protected final voidsetDatabaseDialect(short dialect) Sets the dialect of the database.protected final voidsetOdsMajor(int odsMajor) Sets the ODS (On Disk Structure) major version of the database associated with this connection.protected final voidsetOdsMinor(int odsMinor) Sets the ODS (On Disk Structure) minor version of the database associated with this connection.protected final voidtransactionAdded(FbTransaction transaction) Called when a transaction is added by the database.final voidtransactionStateChanged(FbTransaction transaction, TransactionState newState, TransactionState previousState) Signals that the transaction state changed.Methods inherited from class org.firebirdsql.gds.ng.AbstractFbAttachment
addExceptionListener, checkConnected, forceClose, getDatatypeCoder, getEncoding, getEncodingFactory, getNetworkTimeout, getServerVersion, isAttached, isLockedByCurrentThread, removeExceptionListener, requireNotAttached, safelyDetach, setAttached, setDetached, setServerVersion, withLockMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.firebirdsql.gds.ng.listeners.ExceptionListenable
addExceptionListener, removeExceptionListenerMethods inherited from interface org.firebirdsql.gds.ng.FbAttachment
attach, forceClose, getDatatypeCoder, getEncoding, getEncodingFactory, getNetworkTimeout, getServerVersion, isAttached, isLockedByCurrentThread, setNetworkTimeout, withLockMethods inherited from interface org.firebirdsql.gds.ng.FbDatabase
cancelEvent, cancelOperation, countEvents, createBlobForInput, createBlobForInput, createBlobForInput, createBlobForOutput, createBlobForOutput, createBlobForOutput, createDatabase, createEventHandle, createStatement, dropDatabase, executeImmediate, getDatabaseInfo, getHandle, queueEvent, reconnectTransaction, startTransaction, startTransaction
-
Field Details
-
databaseListenerDispatcher
-
-
Constructor Details
-
AbstractFbDatabase
-
-
Method Details
-
getDatabaseWarningCallback
- Returns:
- The warning callback for this database.
-
getActiveTransactionCount
public final int getActiveTransactionCount()- Returns:
- Number of active (not prepared or committed/rolled back) transactions
-
transactionAdded
Called when a transaction is added by the database.Only this
AbstractFbDatabaseinstance should call this method. -
getConnectionDialect
public final short getConnectionDialect()- Specified by:
getConnectionDialectin interfaceFbDatabase- Returns:
- The client connection dialect
-
getDatabaseDialect
public final short getDatabaseDialect()- Specified by:
getDatabaseDialectin interfaceFbDatabase- Returns:
- The database dialect
-
setDatabaseDialect
protected final void setDatabaseDialect(short dialect) Sets the dialect of the database.This method should only be called by this instance.
- Parameters:
dialect- Dialect of the database/connection
-
addDatabaseListener
Description copied from interface:FbDatabaseAdds aDatabaseListenerinstance to this database.- Specified by:
addDatabaseListenerin interfaceFbDatabase- Parameters:
listener- Database listener
-
addWeakDatabaseListener
Description copied from interface:FbDatabaseAdds aDatabaseListenerinstance to this database using a weak reference.If the listener is already strongly referenced, this call will be ignored
- Specified by:
addWeakDatabaseListenerin interfaceFbDatabase- Parameters:
listener- Database listener
-
removeDatabaseListener
Description copied from interface:FbDatabaseRemoves aDatabaseListenerinstance from this database.- Specified by:
removeDatabaseListenerin interfaceFbDatabase- Parameters:
listener- Database Listener
-
internalDetach
Actual implementation of database detach.Implementations of this method should only be called from
close(), and should not notify database listeners of the databaseDatabaseListener.detaching(FbDatabase)andDatabaseListener.detached(FbDatabase)events.- Throws:
SQLException
-
close
Detaches and closes the connection.Implementation note: Calls
AbstractFbAttachment.checkConnected()and notifies database listeners of the detaching event, then callsinternalDetach()and finally notifies database listeners of database detach and removes all listeners.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceFbAttachment- Throws:
SQLException- If not currently connected, or another problem occurred detaching.
-
getOdsMajor
public final int getOdsMajor()- Specified by:
getOdsMajorin interfaceFbDatabase- Returns:
- ODS major version
-
setOdsMajor
protected final void setOdsMajor(int odsMajor) Sets the ODS (On Disk Structure) major version of the database associated with this connection.This method should only be called by this instance.
- Parameters:
odsMajor- ODS major version
-
getOdsMinor
public final int getOdsMinor()- Specified by:
getOdsMinorin interfaceFbDatabase- Returns:
- ODS minor version
-
setOdsMinor
protected final void setOdsMinor(int odsMinor) Sets the ODS (On Disk Structure) minor version of the database associated with this connection.This method should only be called by this instance.
- Parameters:
odsMinor- ODS minor version
-
getOdsVersion
- Specified by:
getOdsVersionin interfaceFbDatabase- Returns:
- ODS version
-
getStatementInfoRequestItems
public final byte[] getStatementInfoRequestItems()- Returns:
- The (full) statement info request items.
- See Also:
-
getParameterDescriptionInfoRequestItems
public final byte[] getParameterDescriptionInfoRequestItems()- Returns:
- The
isc_info_sql_describe_varsinfo request items. - See Also:
-
getDatabaseInfo
public final <R> R getDatabaseInfo(byte[] requestItems, int bufferLength, InfoProcessor<R> infoProcessor) throws SQLException Description copied from interface:FbDatabaseRequest database info.- Specified by:
getDatabaseInfoin interfaceFbDatabase- Parameters:
requestItems- Array of info items to requestbufferLength- Response buffer length to useinfoProcessor- Implementation ofInfoProcessorto transform the info response- Returns:
- Transformed info response of type T
- Throws:
SQLException- For errors retrieving or transforming the response.
-
getDescribeDatabaseInfoBlock
protected byte[] getDescribeDatabaseInfoBlock() -
getDatabaseInformationProcessor
-
transactionStateChanged
public final void transactionStateChanged(FbTransaction transaction, TransactionState newState, TransactionState previousState) Description copied from interface:TransactionListenerSignals that the transaction state changed.- Specified by:
transactionStateChangedin interfaceTransactionListener- Parameters:
transaction-FbTransactionthat changed state
-
createBlobParameterBuffer
Description copied from interface:FbDatabaseCreates a blob parameter buffer that is usable withFbDatabase.createBlobForInput(FbTransaction, org.firebirdsql.gds.BlobParameterBuffer, long)andFbDatabase.createBlobForOutput(FbTransaction, org.firebirdsql.gds.BlobParameterBuffer)of this instance.- Specified by:
createBlobParameterBufferin interfaceFbDatabase- Returns:
- A blob parameter buffer.
-
createTransactionParameterBuffer
Description copied from interface:FbDatabaseCreates a transaction parameter buffer that is usable withFbDatabase.startTransaction(org.firebirdsql.gds.TransactionParameterBuffer).- Specified by:
createTransactionParameterBufferin interfaceFbDatabase- Returns:
- A transaction parameter buffer
-
getConnectionProperties
- Specified by:
getConnectionPropertiesin interfaceFbDatabase- Returns:
- An immutable copy of the connection properties of this database
-
emptyRowDescriptor
- Specified by:
emptyRowDescriptorin interfaceFbDatabase- Returns:
- A potentially cached empty row descriptor for this database.
-
getTransactionIdBuffer
protected byte[] getTransactionIdBuffer(long transactionId) Encodes the transactionId for use inisc_reconnect_transaction/op_reconnect.- Parameters:
transactionId- transaction id- Returns:
- byte array (4 bytes for max 31-bit transaction id, 8 bytes for larger transaction id)
-