Class V10Database
- 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:
java.lang.AutoCloseable,FbAttachment,FbDatabase,ExceptionListenable,TransactionListener,FbWireAttachment,FbWireDatabase
- Direct Known Subclasses:
V11Database
public class V10Database extends AbstractFbWireDatabase implements FbWireDatabase
FbWireDatabaseimplementation 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
Constructors Modifier Constructor Description protectedV10Database(WireDatabaseConnection connection, ProtocolDescriptor descriptor)Creates a V10Database instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafterAttachActions()Additional tasks to execute directly after attach operation.voidattach()Attach to the attachment type.protected voidattachOrCreate(DatabaseParameterBuffer dpb, boolean create)voidauthReceiveResponse(FbWireAttachment.AcceptPacket acceptPacket)Receive authentication response from the server.voidcancelOperation(int kind)Cancels the current operation.voidcreateDatabase()Creates a new database, connection remains attached to database.FbStatementcreateStatement(FbTransaction transaction)Creates a statement associated with a transactionprotected voiddoReleaseObjectPacket(int operation, int objectId)Sends - without flushing - the (release) operation and objectId.voiddropDatabase()Drops (and deletes) the currently attached database.voidenqueueDeferredAction(DeferredAction deferredAction)Enqueue a deferred action.voidexecuteImmediate(java.lang.String statementText, FbTransaction transaction)Performs an execute immediate of a statement.BlrCalculatorgetBlrCalculator()byte[]getDatabaseInfo(byte[] requestItems, int maxBufferLength)Performs a database info request.protected EncodinggetFilenameEncoding(DatabaseParameterBuffer dpb)Gets theEncodingto use for the database filename.intgetHandle()protected byte[]getTransactionIdBuffer(long transactionId)FbWireAsynchronousChannelinitAsynchronousChannel()Initializes the asynchronous channel (for event notification).protected voidinternalDetach()Actual implementation of database detach.protected voidprocessAttachOrCreateResponse(GenericResponse genericResponse)Processes the response from the server to the attach or create operation.protected voidprocessReleaseObjectResponse(Response response)Process the release object responseFbTransactionreconnectTransaction(long transactionId)Reconnects a prepared transaction.voidreleaseObject(int operation, int objectId)Release object.protected voidsendAttachOrCreateToBuffer(DatabaseParameterBuffer dpb, boolean create)Sends the buffer for op_attach or op_createFbWireTransactionstartTransaction(TransactionParameterBuffer tpb)Creates and starts a transaction.-
Methods inherited from class org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase
cancelEvent, checkAttached, checkConnected, closeConnection, consumePackets, countEvents, createBlobForInput, createBlobForOutput, createEventHandle, finalize, forceClose, 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, getParameterDescriptionInfoRequestItems, getStatementInfoRequestItems, removeDatabaseListener, setDatabaseDialect, setOdsMajor, setOdsMinor, transactionAdded, transactionStateChanged
-
Methods inherited from class org.firebirdsql.gds.ng.AbstractFbAttachment
addExceptionListener, getDatatypeCoder, getEncoding, getEncodingFactory, getNetworkTimeout, getServerVersion, getServerVersionInformation, getSynchronizationObject, removeExceptionListener, safelyDetach, setAttached, setDetached, setServerVersion
-
Methods inherited from class java.lang.Object
clone, equals, 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, getSynchronizationObject, isAttached, setNetworkTimeout
-
Methods inherited from interface org.firebirdsql.gds.ng.FbDatabase
addDatabaseListener, addWeakDatabaseListener, cancelEvent, countEvents, createBlobForInput, createBlobForOutput, createBlobParameterBuffer, createEventHandle, createTransactionParameterBuffer, emptyRowDescriptor, getConnectionDialect, getConnectionProperties, getDatabaseDialect, getDatabaseInfo, getOdsMajor, getOdsMinor, queueEvent, removeDatabaseListener
-
Methods inherited from interface org.firebirdsql.gds.ng.wire.FbWireAttachment
getXdrStreamAccess, readGenericResponse
-
Methods inherited from interface org.firebirdsql.gds.ng.wire.FbWireDatabase
consumePackets, readResponse, readSqlResponse
-
-
-
-
Constructor Detail
-
V10Database
protected V10Database(WireDatabaseConnection connection, ProtocolDescriptor descriptor)
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 Detail
-
getHandle
public final int getHandle()
- Specified by:
getHandlein interfaceFbAttachment- Specified by:
getHandlein interfaceFbDatabase- Returns:
- The database handle value
-
attach
public final void attach() throws java.sql.SQLExceptionDescription copied from interface:FbAttachmentAttach to the attachment type.- Specified by:
attachin interfaceFbAttachment- Throws:
java.sql.SQLException
-
attachOrCreate
protected final void attachOrCreate(DatabaseParameterBuffer dpb, boolean create) throws java.sql.SQLException
- Parameters:
dpb- Database parameter buffercreate-truecreate database,falseonly attach- Throws:
java.sql.SQLException- For errors during attach or create
-
sendAttachOrCreateToBuffer
protected final void sendAttachOrCreateToBuffer(DatabaseParameterBuffer dpb, boolean create) throws java.sql.SQLException, java.io.IOException
Sends the buffer for op_attach or op_create- Parameters:
dpb- Database parameter buffercreate-truecreate database,falseonly attach- Throws:
java.sql.SQLException- If the connection is not openjava.io.IOException- For errors writing to the connection
-
getFilenameEncoding
protected Encoding getFilenameEncoding(DatabaseParameterBuffer dpb)
Gets theEncodingto use for the database filename.- Parameters:
dpb- Database parameter buffer- Returns:
- Encoding
-
processAttachOrCreateResponse
protected final void processAttachOrCreateResponse(GenericResponse genericResponse)
Processes the response from the server to the attach or create operation.- Parameters:
genericResponse- GenericResponse received from the server.
-
afterAttachActions
protected final void afterAttachActions() throws java.sql.SQLExceptionAdditional tasks to execute directly after attach operation.Implementation retrieves database information like dialect ODS and server version.
- Throws:
java.sql.SQLException- For errors reading or writing database information.
-
internalDetach
protected final void internalDetach() throws java.sql.SQLExceptionDescription copied from class:AbstractFbDatabaseActual 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:
internalDetachin classAbstractFbDatabase<WireDatabaseConnection>- Throws:
java.sql.SQLException
-
createDatabase
public final void createDatabase() throws java.sql.SQLExceptionDescription copied from interface:FbDatabaseCreates a new database, connection remains attached to database.- Specified by:
createDatabasein interfaceFbDatabase- Throws:
java.sql.SQLException
-
dropDatabase
public final void dropDatabase() throws java.sql.SQLExceptionDescription copied from interface:FbDatabaseDrops (and deletes) the currently attached database.- Specified by:
dropDatabasein interfaceFbDatabase- Throws:
java.sql.SQLException
-
startTransaction
public final FbWireTransaction startTransaction(TransactionParameterBuffer tpb) throws java.sql.SQLException
Description copied from interface:FbDatabaseCreates and starts a transaction.- Specified by:
startTransactionin interfaceFbDatabase- Parameters:
tpb- TransactionParameterBuffer with the required transaction options- Returns:
- FbTransaction
- Throws:
java.sql.SQLException
-
reconnectTransaction
public final FbTransaction reconnectTransaction(long transactionId) throws java.sql.SQLException
Description copied from interface:FbDatabaseReconnects a prepared transaction.Reconnecting transactions is only allowed for transactions in limbo (prepared, but not committed or rolled back).
- Specified by:
reconnectTransactionin interfaceFbDatabase- Parameters:
transactionId- The id of the transaction to reconnect.- Returns:
- FbTransaction
- Throws:
java.sql.SQLException- For errors reconnecting the transaction
-
getTransactionIdBuffer
protected byte[] getTransactionIdBuffer(long transactionId)
-
createStatement
public final FbStatement createStatement(FbTransaction transaction) throws java.sql.SQLException
Description copied from interface:FbDatabaseCreates a statement associated with a transaction- Specified by:
createStatementin interfaceFbDatabase- Parameters:
transaction- FbTransaction to associate with this statement (can benull).- Returns:
- FbStatement
- Throws:
java.sql.SQLException
-
cancelOperation
public void cancelOperation(int kind) throws java.sql.SQLExceptionDescription copied from interface:FbDatabaseCancels 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:
cancelOperationin interfaceFbDatabase- Parameters:
kind- Cancellation type- Throws:
java.sql.SQLException- For errors cancelling, or if the cancel operation is not supported.
-
getDatabaseInfo
public final byte[] getDatabaseInfo(byte[] requestItems, int maxBufferLength) throws java.sql.SQLExceptionDescription copied from interface:FbDatabasePerforms a database info request.- Specified by:
getDatabaseInfoin interfaceFbDatabase- Parameters:
requestItems- Information items to requestmaxBufferLength- 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.
-
executeImmediate
public final void executeImmediate(java.lang.String statementText, FbTransaction transaction) throws java.sql.SQLExceptionDescription copied from interface:FbDatabasePerforms an execute immediate of a statement.A call to this method is the equivalent of a
isc_dsql_execute_immediate()without parameters.- Specified by:
executeImmediatein interfaceFbDatabase- Parameters:
statementText- Statement texttransaction- Transaction (nullonly allowed if database is not attached!)- Throws:
java.sql.SQLException- For errors executing the statement, or iftransactionisnullwhen the database is attached or notnullwhen the database is not attached
-
releaseObject
public void releaseObject(int operation, int objectId) throws java.sql.SQLExceptionDescription copied from interface:FbWireDatabaseRelease object.- Specified by:
releaseObjectin interfaceFbWireDatabase- Parameters:
operation- OperationobjectId- Id of the object to release- Throws:
java.sql.SQLException
-
initAsynchronousChannel
public final FbWireAsynchronousChannel initAsynchronousChannel() throws java.sql.SQLException
Description copied from class:AbstractFbWireDatabaseInitializes the asynchronous channel (for event notification).- Specified by:
initAsynchronousChannelin classAbstractFbWireDatabase- Throws:
java.sql.SQLException- For errors establishing the channel, or if the channel already exists.
-
doReleaseObjectPacket
protected final void doReleaseObjectPacket(int operation, int objectId) throws java.io.IOException, java.sql.SQLExceptionSends - without flushing - the (release) operation and objectId.- Parameters:
operation- OperationobjectId- Id of the object to release- Throws:
java.io.IOException- For errors writing to the connectionjava.sql.SQLException- If the database connection is not available
-
processReleaseObjectResponse
protected final void processReleaseObjectResponse(Response response)
Process the release object response- Parameters:
response- The response object
-
getBlrCalculator
public final BlrCalculator getBlrCalculator()
- Specified by:
getBlrCalculatorin interfaceFbWireDatabase- Returns:
- The
BlrCalculatorinstance for this database.
-
enqueueDeferredAction
public void enqueueDeferredAction(DeferredAction deferredAction)
Description copied from interface:FbWireDatabaseEnqueue a deferred action.FbDatabase implementations that do not support deferred actions are allowed to throw an
UnsupportedOperationException- Specified by:
enqueueDeferredActionin interfaceFbWireDatabase- Parameters:
deferredAction- Deferred action
-
authReceiveResponse
public final void authReceiveResponse(FbWireAttachment.AcceptPacket acceptPacket) throws java.io.IOException, java.sql.SQLException
Description copied from interface:FbWireAttachmentReceive authentication response from the server.This method is only relevant for protocol V13 or higher.
- Specified by:
authReceiveResponsein interfaceFbWireAttachment- Parameters:
acceptPacket- Packet withop_cond_acceptdata, ornullwhen the data should be read from the connection.- Throws:
java.io.IOException- For errors reading the response from the connection.java.sql.SQLException- For errors returned from the server, or when attempting to read.
-
-