- All Implemented Interfaces:
AutoCloseable,FbAttachment,FbDatabase,ExceptionListenable,TransactionListener,FbWireAttachment,FbWireDatabase
- Direct Known Subclasses:
V10Database
- 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
FieldsModifier and TypeFieldDescriptionprotected final ProtocolDescriptorprotected final FbWireOperationsFields inherited from class org.firebirdsql.gds.ng.AbstractFbDatabase
databaseListenerDispatcherFields inherited from class org.firebirdsql.gds.ng.AbstractFbAttachment
connection, exceptionListenerDispatcher -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractFbWireDatabase(WireDatabaseConnection connection, ProtocolDescriptor descriptor) Creates an AbstractFbWireDatabase instance. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidcancelEvent(EventHandle eventHandle) Cancels a registered event.protected final voidChecks if a physical connection to the server is established and if the connection is attached to a database.protected final voidChecks if a physical connection to the server is established.protected final voidCloses the WireConnection associated with this connection.final voidCompletes pending deferred actions.final voidconsumePackets(int numberOfResponses, WarningMessageCallback warningCallback) Consumes packets notifying for warnings, but ignoring exceptions thrown from the packet.final voidcountEvents(EventHandle eventHandle) Counts the events occurred.final FbBlobcreateBlobForInput(FbTransaction transaction, BlobParameterBuffer blobParameterBuffer, long blobId) Creates a blob for read access to an existing blob on the server.final FbBlobcreateBlobForOutput(FbTransaction transaction, BlobParameterBuffer blobParameterBuffer) Creates a blob for write access to a new blob on the server.final EventHandlecreateEventHandle(String eventName, EventHandler eventHandler) Creates an event handle for this database type.final voidenqueueDeferredAction(DeferredAction deferredAction) Enqueue a deferred action.voidForces the connection to close without proper detach or cleanup.final byte[]getDatabaseInfo(byte[] requestItems, int maxBufferLength) Performs a database info request.final intbyte[]getInfo(int operation, int handle, byte[] requestItems, int maxBufferLength, WarningMessageCallback warningMessageCallback) Generic info request.final FbWireOperationsprotected final XdrInputStreamgetXdrIn()Gets the XdrInputStream.protected final XdrOutputStreamGets the XdrOutputStream.final XdrStreamAccessabstract FbWireAsynchronousChannelInitializes the asynchronous channel (for event notification).final booleanCurrent attachment status.final voidqueueEvent(EventHandle eventHandle) Queues a wait for an event.final GenericResponsereadGenericResponse(WarningMessageCallback warningCallback) Convenience method to read a Response to a GenericResponsefinal ResponsereadResponse(WarningMessageCallback warningCallback) Reads the response from the server.final SqlResponsereadSqlResponse(WarningMessageCallback warningCallback) Convenience method to read a Response to a SqlResponsevoidsetNetworkTimeout(int milliseconds) Sets the network timeout for this attachment.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, internalDetach, removeDatabaseListener, setDatabaseDialect, setOdsMajor, setOdsMinor, transactionAdded, transactionStateChangedMethods inherited from class org.firebirdsql.gds.ng.AbstractFbAttachment
addExceptionListener, getDatatypeCoder, getEncoding, getEncodingFactory, getNetworkTimeout, getServerVersion, 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, close, getDatatypeCoder, getEncoding, getEncodingFactory, getNetworkTimeout, getServerVersion, isLockedByCurrentThread, withLockMethods inherited from interface org.firebirdsql.gds.ng.FbDatabase
addDatabaseListener, addWeakDatabaseListener, cancelOperation, createBlobForInput, createBlobForInput, createBlobForOutput, createBlobForOutput, createBlobParameterBuffer, createDatabase, createStatement, createTransactionParameterBuffer, dropDatabase, emptyRowDescriptor, executeImmediate, getConnectionDialect, getConnectionProperties, getDatabaseDialect, getDatabaseInfo, getOdsMajor, getOdsMinor, getOdsVersion, reconnectTransaction, removeDatabaseListener, startTransaction, startTransactionMethods inherited from interface org.firebirdsql.gds.ng.wire.FbWireAttachment
authReceiveResponseMethods inherited from interface org.firebirdsql.gds.ng.wire.FbWireDatabase
getBlrCalculator, releaseObject
-
Field Details
-
protocolDescriptor
-
wireOperations
-
-
Constructor Details
-
AbstractFbWireDatabase
Creates an AbstractFbWireDatabase 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
-
getHandle
public final int getHandle()- Specified by:
getHandlein interfaceFbAttachment- Specified by:
getHandlein interfaceFbDatabase- Returns:
- The database handle value
-
forceClose
Description copied from class:AbstractFbAttachmentForces the connection to close without proper detach or cleanup.If a given implementation does not support this, then this method should call
FbAttachment.close().Default implementation, calls
FbAttachment.close()- Specified by:
forceClosein interfaceFbAttachment- Overrides:
forceClosein classAbstractFbAttachment<WireDatabaseConnection>- Throws:
SQLException- For problems closing the connection.
-
getXdrIn
Gets the XdrInputStream.- Returns:
- Instance of XdrInputStream
- Throws:
SQLException- If no connection is opened or when exceptions occur retrieving the InputStream
-
getXdrOut
Gets the XdrOutputStream.- Returns:
- Instance of XdrOutputStream
- Throws:
SQLException- If no connection is opened or when exceptions occur retrieving the OutputStream
-
getXdrStreamAccess
- Specified by:
getXdrStreamAccessin interfaceFbWireAttachment- Returns:
- Instance of
XdrStreamAccessfor this attachment.
-
getWireOperations
- Specified by:
getWireOperationsin interfaceFbWireAttachment- Returns:
- Instance of
FbWireOperationsfor this attachment.
-
isAttached
public final boolean isAttached()Description copied from interface:FbAttachmentCurrent attachment status.- Specified by:
isAttachedin interfaceFbAttachment- Overrides:
isAttachedin classAbstractFbAttachment<WireDatabaseConnection>- Returns:
trueif connected to the server and attached to a database or service,falseotherwise.
-
checkConnected
Checks if a physical connection to the server is established.- Specified by:
checkConnectedin classAbstractFbAttachment<WireDatabaseConnection>- Throws:
SQLException- If not connected.
-
checkAttached
Checks if a physical connection to the server is established and if the connection is attached to a database.This method calls
checkConnected(), so it is not necessary to call both.- Throws:
SQLException- If the database not connected or attached.
-
closeConnection
Closes the WireConnection associated with this connection.- Throws:
IOException- For errors closing the connection.
-
setNetworkTimeout
Description copied from interface:FbAttachmentSets the network timeout for this attachment.- Specified by:
setNetworkTimeoutin interfaceFbAttachment- Parameters:
milliseconds- Timeout in milliseconds; 0 means no timeout. If the attachment doesn't support milliseconds, it should round up to the nearest second.- Throws:
SQLException- If this attachment is closed, the value ofmillisecondsis smaller than 0, or if setting the timeout fails.SQLFeatureNotSupportedException- If this attachment doesn't support (changing) the network timeout.
-
createBlobForOutput
public final FbBlob createBlobForOutput(FbTransaction transaction, BlobParameterBuffer blobParameterBuffer) throws SQLException Description copied from interface:FbDatabaseCreates a blob for write access to a new blob on the server.The blob is initially closed.
- Specified by:
createBlobForOutputin interfaceFbDatabase- Parameters:
transaction- transaction associated with the blobblobParameterBuffer- blob parameter buffer- Returns:
- instance of
FbBlob - Throws:
SQLException- if the database is not attached or the transaction is not active
-
createBlobForInput
public final FbBlob createBlobForInput(FbTransaction transaction, BlobParameterBuffer blobParameterBuffer, long blobId) throws SQLException Description copied from interface:FbDatabaseCreates a blob for read access to an existing blob on the server.The blob is initially closed.
- Specified by:
createBlobForInputin interfaceFbDatabase- Parameters:
transaction- transaction associated with the blobblobParameterBuffer- blob parameter bufferblobId- id of the blob- Returns:
- instance of
FbBlob - Throws:
SQLException- if the database is not attached or the transaction is not active
-
consumePackets
Description copied from interface:FbWireDatabaseConsumes packets notifying for warnings, but ignoring exceptions thrown from the packet.This method should only be used inside the implementation if either packets need to be ignored, or to ensure that there is no backlog of packets (eg when an exception occurs during processing of multiple package responses).
- Specified by:
consumePacketsin interfaceFbWireDatabase- Parameters:
numberOfResponses- Number of responses to consume.warningCallback- Callback for warnings
-
readGenericResponse
public final GenericResponse readGenericResponse(WarningMessageCallback warningCallback) throws SQLException, IOException Description copied from interface:FbWireAttachmentConvenience method to read a Response to a GenericResponse- Specified by:
readGenericResponsein interfaceFbWireAttachment- Parameters:
warningCallback- Callback object for warnings,nullfor default callback- Returns:
- GenericResponse
- Throws:
SQLException- For errors returned from the server, or when attempting to read.IOException- For errors reading the response from the connection.
-
readSqlResponse
public final SqlResponse readSqlResponse(WarningMessageCallback warningCallback) throws SQLException, IOException Description copied from interface:FbWireDatabaseConvenience method to read a Response to a SqlResponse- Specified by:
readSqlResponsein interfaceFbWireDatabase- Parameters:
warningCallback- Callback object for warnings,nullfor default callback- Returns:
- SqlResponse
- Throws:
SQLException- For errors returned from the server, or when attempting to read.IOException- For errors reading the response from the connection.
-
readResponse
public final Response readResponse(WarningMessageCallback warningCallback) throws SQLException, IOException Description copied from interface:FbWireDatabaseReads the response from the server.- Specified by:
readResponsein interfaceFbWireDatabase- Parameters:
warningCallback- Callback object for warnings,nullfor default callback- Returns:
Responseread.- Throws:
SQLException- For errors returned from the server, or when attempting to readIOException- For errors reading the response from the connection.
-
enqueueDeferredAction
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- Throws:
SQLException- for errors forcing handling of oversized queue usingop_ping(orop_batch_sync)
-
completeDeferredActions
Description copied from interface:FbWireDatabaseCompletes pending deferred actions.FbDatabase implementations that do not support deferred actions should simply do nothing.
- Specified by:
completeDeferredActionsin interfaceFbWireDatabase- Throws:
SQLException- for errors forcing ping/batch sync
-
createEventHandle
Description copied from interface:FbDatabaseCreates an event handle for this database type.The returned event handle can be used with
FbDatabase.queueEvent(org.firebirdsql.gds.EventHandle).- Specified by:
createEventHandlein interfaceFbDatabase- Parameters:
eventName- Name of the eventeventHandler- The event handler to call when the event occurred- Returns:
- A suitable event handle instance
-
queueEvent
Description copied from interface:FbDatabaseQueues a wait for an event.- Specified by:
queueEventin interfaceFbDatabase- Parameters:
eventHandle- The event handle (created usingFbDatabase.createEventHandle(String, EventHandler)of this instance).- Throws:
SQLException- For errors establishing the asynchronous channel, or for queuing the event.
-
cancelEvent
Description copied from interface:FbDatabaseCancels a registered event.After cancellation, the event handle should be considered unusable. Before queueing a new event, an new handle needs to be created.
- Specified by:
cancelEventin interfaceFbDatabase- Parameters:
eventHandle- The event handle to cancel- Throws:
SQLException- For errors cancelling the event
-
countEvents
Description copied from interface:FbDatabaseCounts the events occurred.- Specified by:
countEventsin interfaceFbDatabase- Parameters:
eventHandle- The event handle- Throws:
SQLException- When the count can not be done (as - for example - the event handle is of the wrong type)
-
getDatabaseInfo
Description 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:
SQLException- For errors retrieving the information.
-
getInfo
public byte[] getInfo(int operation, int handle, byte[] requestItems, int maxBufferLength, WarningMessageCallback warningMessageCallback) throws SQLException Description copied from interface:FbWireDatabaseGeneric info request.The implementation does not perform handle validation nor notification of error dispatchers. Doing that is the responsibility of the caller.
- Specified by:
getInfoin interfaceFbWireDatabase- Parameters:
operation- Operation codehandle- Handle (db, transaction, statement, blob, etc)requestItems- Information items to requestmaxBufferLength- Maximum response buffer length to usewarningMessageCallback- Callback for warnings when reading the response (can benullto use database default)- Returns:
- The response buffer (note: length is the actual length of the response, not
maxBufferLength) - Throws:
SQLException- For errors retrieving the information
-
initAsynchronousChannel
Initializes the asynchronous channel (for event notification).- Throws:
SQLException- For errors establishing the channel, or if the channel already exists.
-