java.lang.Object
org.firebirdsql.gds.ng.AbstractFbAttachment<T>
org.firebirdsql.gds.ng.AbstractFbDatabase<WireDatabaseConnection>
org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase
org.firebirdsql.gds.ng.wire.version10.V10Database
- All Implemented Interfaces:
AutoCloseable
,FbAttachment
,FbDatabase
,ExceptionListenable
,TransactionListener
,FbWireAttachment
,FbWireDatabase
- Direct Known Subclasses:
V11Database
FbWireDatabase
implementation for the version 10 wire protocol.- Since:
- 3.0
- Author:
- Mark Rotteveel
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.firebirdsql.gds.ng.wire.FbWireAttachment
FbWireAttachment.AcceptPacket
-
Field Summary
Fields inherited from class org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase
protocolDescriptor, wireOperations
Fields inherited from class org.firebirdsql.gds.ng.AbstractFbDatabase
databaseListenerDispatcher
Fields inherited from class org.firebirdsql.gds.ng.AbstractFbAttachment
connection, exceptionListenerDispatcher
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
V10Database
(WireDatabaseConnection connection, ProtocolDescriptor descriptor) Creates a V10Database instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
Additional tasks to execute directly after attach operation.final void
attach()
Attach to the attachment type.protected final void
attachOrCreate
(DatabaseParameterBuffer dpb, boolean create) final void
authReceiveResponse
(FbWireAttachment.AcceptPacket acceptPacket) Receive authentication response from the server.void
cancelOperation
(int kind) Cancels the current operation.final void
Creates a new database, connection remains attached to database.final FbStatement
createStatement
(FbTransaction transaction) Creates a statement associated with a transactionprotected final void
doReleaseObjectPacket
(int operation, int objectId) Sends - without flushing - the (release) operation and objectId.final void
Drops (and deletes) the currently attached database.final void
executeImmediate
(String statementText, FbTransaction transaction) Performs an execute immediate of a statement.final BlrCalculator
protected Encoding
Gets theEncoding
to use for the database filename.Initializes the asynchronous channel (for event notification).protected final void
Actual implementation of database detach.protected final void
processAttachOrCreateResponse
(GenericResponse genericResponse) Processes the response from the server to the attach or create operation.protected final void
processReleaseObjectResponse
(Response response) Process the release object responsefinal FbTransaction
reconnectTransaction
(long transactionId) Reconnects a prepared transaction.void
releaseObject
(int operation, int objectId) Release object.protected final void
sendAttachOrCreateToBuffer
(DatabaseParameterBuffer dpb, boolean create) Sends the buffer for op_attach or op_createstartTransaction
(String statementText) Creates and starts a transaction using a SQL statementfinal FbWireTransaction
Creates and starts a transaction.Methods inherited from class org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase
cancelEvent, checkAttached, checkConnected, closeConnection, completeDeferredActions, consumePackets, countEvents, createBlobForInput, createBlobForOutput, createEventHandle, enqueueDeferredAction, forceClose, getDatabaseInfo, getHandle, getInfo, getWireOperations, getXdrIn, getXdrOut, getXdrStreamAccess, isAttached, queueEvent, readGenericResponse, readResponse, readSqlResponse, setNetworkTimeout
Methods inherited from class org.firebirdsql.gds.ng.AbstractFbDatabase
addDatabaseListener, addWeakDatabaseListener, close, createBlobParameterBuffer, createTransactionParameterBuffer, emptyRowDescriptor, getActiveTransactionCount, getConnectionDialect, getConnectionProperties, getDatabaseDialect, getDatabaseInfo, getDatabaseInformationProcessor, getDatabaseWarningCallback, getDescribeDatabaseInfoBlock, getOdsMajor, getOdsMinor, getOdsVersion, getParameterDescriptionInfoRequestItems, getStatementInfoRequestItems, getTransactionIdBuffer, removeDatabaseListener, setDatabaseDialect, setOdsMajor, setOdsMinor, transactionAdded, transactionStateChanged
Methods inherited from class org.firebirdsql.gds.ng.AbstractFbAttachment
addExceptionListener, getDatatypeCoder, getEncoding, getEncodingFactory, getNetworkTimeout, getServerVersion, isLockedByCurrentThread, removeExceptionListener, requireNotAttached, safelyDetach, setAttached, setDetached, setServerVersion, withLock
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.firebirdsql.gds.ng.listeners.ExceptionListenable
addExceptionListener, removeExceptionListener
Methods inherited from interface org.firebirdsql.gds.ng.FbAttachment
close, forceClose, getDatatypeCoder, getEncoding, getEncodingFactory, getNetworkTimeout, getServerVersion, isAttached, isLockedByCurrentThread, setNetworkTimeout, withLock
Methods inherited from interface org.firebirdsql.gds.ng.FbDatabase
addDatabaseListener, addWeakDatabaseListener, cancelEvent, countEvents, createBlobForInput, createBlobForInput, createBlobForInput, createBlobForOutput, createBlobForOutput, createBlobForOutput, createBlobParameterBuffer, createEventHandle, createTransactionParameterBuffer, emptyRowDescriptor, getConnectionDialect, getConnectionProperties, getDatabaseDialect, getDatabaseInfo, getDatabaseInfo, getHandle, getOdsMajor, getOdsMinor, getOdsVersion, queueEvent, removeDatabaseListener
Methods inherited from interface org.firebirdsql.gds.ng.wire.FbWireAttachment
getWireOperations, getXdrStreamAccess, readGenericResponse
Methods inherited from interface org.firebirdsql.gds.ng.wire.FbWireDatabase
completeDeferredActions, consumePackets, enqueueDeferredAction, getInfo, readResponse, readSqlResponse
-
Constructor Details
-
V10Database
Creates a V10Database instance.- Parameters:
connection
- A WireConnection with an established connection to the server.descriptor
- The ProtocolDescriptor that created this connection (this is used for creating further dependent objects).
-
-
Method Details
-
attach
Description copied from interface:FbAttachment
Attach to the attachment type.- Specified by:
attach
in interfaceFbAttachment
- Throws:
SQLException
-
attachOrCreate
protected final void attachOrCreate(DatabaseParameterBuffer dpb, boolean create) throws SQLException - Parameters:
dpb
- Database parameter buffercreate
-true
create database,false
only attach- Throws:
SQLException
- For errors during attach or create
-
sendAttachOrCreateToBuffer
protected final void sendAttachOrCreateToBuffer(DatabaseParameterBuffer dpb, boolean create) throws SQLException, IOException Sends the buffer for op_attach or op_create- Parameters:
dpb
- Database parameter buffercreate
-true
create database,false
only attach- Throws:
SQLException
- If the connection is not openIOException
- For errors writing to the connection
-
getFilenameEncoding
Gets theEncoding
to use for the database filename.- Parameters:
dpb
- Database parameter buffer- Returns:
- Encoding
-
processAttachOrCreateResponse
Processes the response from the server to the attach or create operation.- Parameters:
genericResponse
- GenericResponse received from the server.
-
afterAttachActions
Additional tasks to execute directly after attach operation.Implementation retrieves database information like dialect ODS and server version.
- Throws:
SQLException
- For errors reading or writing database information.
-
internalDetach
Description copied from class:AbstractFbDatabase
Actual implementation of database detach.Implementations of this method should only be called from
AbstractFbDatabase.close()
, and should not notify database listeners of the databaseDatabaseListener.detaching(FbDatabase)
andDatabaseListener.detached(FbDatabase)
events.- Specified by:
internalDetach
in classAbstractFbDatabase<WireDatabaseConnection>
- Throws:
SQLException
-
createDatabase
Description copied from interface:FbDatabase
Creates a new database, connection remains attached to database.- Specified by:
createDatabase
in interfaceFbDatabase
- Throws:
SQLException
-
dropDatabase
Description copied from interface:FbDatabase
Drops (and deletes) the currently attached database.- Specified by:
dropDatabase
in interfaceFbDatabase
- Throws:
SQLException
-
startTransaction
Description copied from interface:FbDatabase
Creates and starts a transaction.- Specified by:
startTransaction
in interfaceFbDatabase
- Parameters:
tpb
- TransactionParameterBuffer with the required transaction options- Returns:
- FbTransaction
- Throws:
SQLException
-
startTransaction
Description copied from interface:FbDatabase
Creates and starts a transaction using a SQL statement- Specified by:
startTransaction
in interfaceFbDatabase
- Parameters:
statementText
- statement which starts a transaction- Returns:
- FbTransaction
- Throws:
SQLException
- for database access error
-
reconnectTransaction
Description copied from interface:FbDatabase
Reconnects a prepared transaction.Reconnecting transactions is only allowed for transactions in limbo (prepared, but not committed or rolled back).
- Specified by:
reconnectTransaction
in interfaceFbDatabase
- Parameters:
transactionId
- The id of the transaction to reconnect.- Returns:
- FbTransaction
- Throws:
SQLException
- For errors reconnecting the transaction
-
createStatement
Description copied from interface:FbDatabase
Creates a statement associated with a transaction- Specified by:
createStatement
in interfaceFbDatabase
- Parameters:
transaction
- FbTransaction to associate with this statement (can benull
)- Returns:
- FbStatement
- Throws:
SQLException
-
cancelOperation
Description copied from interface:FbDatabase
Cancels 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!
- Specified by:
cancelOperation
in interfaceFbDatabase
- Parameters:
kind
- Cancellation type- Throws:
SQLException
- For errors cancelling, or if the cancel operation is not supported.
-
executeImmediate
public final void executeImmediate(String statementText, FbTransaction transaction) throws SQLException Description copied from interface:FbDatabase
Performs an execute immediate of a statement.A call to this method is the equivalent of a
isc_dsql_execute_immediate()
without parameters.- Specified by:
executeImmediate
in interfaceFbDatabase
- Parameters:
statementText
- Statement texttransaction
- Transaction (null
only allowed if database is not attached!)- Throws:
SQLException
- For errors executing the statement, or iftransaction
isnull
when the database is attached or notnull
when the database is not attached
-
releaseObject
Description copied from interface:FbWireDatabase
Release object.- Specified by:
releaseObject
in interfaceFbWireDatabase
- Parameters:
operation
- OperationobjectId
- ID of the object to release- Throws:
SQLException
-
initAsynchronousChannel
Description copied from class:AbstractFbWireDatabase
Initializes the asynchronous channel (for event notification).- Specified by:
initAsynchronousChannel
in classAbstractFbWireDatabase
- Throws:
SQLException
- For errors establishing the channel, or if the channel already exists.
-
doReleaseObjectPacket
protected final void doReleaseObjectPacket(int operation, int objectId) throws IOException, SQLException Sends - without flushing - the (release) operation and objectId.- Parameters:
operation
- OperationobjectId
- Id of the object to release- Throws:
IOException
- For errors writing to the connectionSQLException
- If the database connection is not available
-
processReleaseObjectResponse
Process the release object response- Parameters:
response
- The response object
-
getBlrCalculator
- Specified by:
getBlrCalculator
in interfaceFbWireDatabase
- Returns:
- The
BlrCalculator
instance for this database.
-
authReceiveResponse
public final void authReceiveResponse(FbWireAttachment.AcceptPacket acceptPacket) throws IOException, SQLException Description copied from interface:FbWireAttachment
Receive authentication response from the server.This method is only relevant for protocol V13 or higher.
- Specified by:
authReceiveResponse
in interfaceFbWireAttachment
- Parameters:
acceptPacket
- Packet withop_cond_accept
data, ornull
when the data should be read from the connection.- Throws:
IOException
- For errors reading the response from the connection.SQLException
- For errors returned from the server, or when attempting to read.
-