public class JnaDatabase extends AbstractFbDatabase<JnaDatabaseConnection> implements JnaAttachment, TransactionListener, FbClientFeatureAccess
FbDatabase for native client access.| Modifier and Type | Field and Description |
|---|---|
protected com.sun.jna.ptr.IntByReference |
handle |
static int |
MAX_STATEMENT_LENGTH |
static int |
STATUS_VECTOR_SIZE |
protected ISC_STATUS[] |
statusVector |
databaseListenerDispatcherconnection, exceptionListenerDispatcher| Constructor and Description |
|---|
JnaDatabase(JnaDatabaseConnection connection) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterAttachActions()
Additional tasks to execute directly after attach operation.
|
void |
attach()
Attach to the attachment type.
|
protected void |
attachOrCreate(DatabaseParameterBuffer dpb,
boolean create) |
void |
cancelEvent(EventHandle eventHandle)
Cancels a registered event.
|
void |
cancelOperation(int kind)
Cancels the current operation.
|
protected void |
checkConnected()
Checks if the attachment is connected, and throws a
SQLException if it isn't connected. |
void |
countEvents(EventHandle eventHandle)
Counts the events occurred.
|
FbBlob |
createBlobForInput(FbTransaction transaction,
BlobParameterBuffer blobParameterBuffer,
long blobId)
Creates a blob for read access to an existing blob on the server.
|
FbBlob |
createBlobForOutput(FbTransaction transaction,
BlobParameterBuffer blobParameterBuffer)
Creates a blob for write access to a new blob on the server.
|
void |
createDatabase()
Creates a new database, connection remains attached to database.
|
JnaEventHandle |
createEventHandle(java.lang.String eventName,
EventHandler eventHandler)
Creates an event handle for this database type.
|
JnaStatement |
createStatement(FbTransaction transaction)
Creates a statement associated with a transaction
|
void |
dropDatabase()
Drops (and deletes) the currently attached database.
|
void |
executeImmediate(java.lang.String statementText,
FbTransaction transaction)
Performs an execute immediate of a statement.
|
protected void |
finalize() |
protected FbClientLibrary |
getClientLibrary() |
byte[] |
getDatabaseInfo(byte[] requestItems,
int maxBufferLength)
Performs a database info request.
|
EncodingDefinition |
getEncodingDefinition() |
java.util.Set<FbClientFeature> |
getFeatures() |
int |
getHandle() |
com.sun.jna.ptr.IntByReference |
getJnaHandle() |
int |
getNetworkTimeout()
Gets the current network timeout for this attachment.
|
protected byte[] |
getTransactionIdBuffer(long transactionId) |
boolean |
hasFeature(FbClientFeature clientFeature)
Checks for presence of a client feature.
|
protected void |
internalDetach()
Actual implementation of database detach.
|
void |
processStatusVector(ISC_STATUS[] statusVector,
WarningMessageCallback warningMessageCallback) |
void |
queueEvent(EventHandle eventHandle)
Queues a wait for an event.
|
FbTransaction |
reconnectTransaction(long transactionId)
Reconnects a prepared transaction.
|
void |
setNetworkTimeout(int milliseconds)
Sets the network timeout for this attachment.
|
JnaTransaction |
startTransaction(TransactionParameterBuffer tpb)
Creates and starts a transaction.
|
protected JnaEventHandle |
validateEventHandle(EventHandle eventHandle) |
addDatabaseListener, addWeakDatabaseListener, close, createBlobParameterBuffer, createTransactionParameterBuffer, emptyRowDescriptor, getActiveTransactionCount, getConnectionDialect, getConnectionProperties, getDatabaseDialect, getDatabaseInfo, getDatabaseInformationProcessor, getDatabaseWarningCallback, getDescribeDatabaseInfoBlock, getOdsMajor, getOdsMinor, getParameterDescriptionInfoRequestItems, getStatementInfoRequestItems, removeDatabaseListener, setDatabaseDialect, setOdsMajor, setOdsMinor, transactionAdded, transactionStateChangedaddExceptionListener, forceClose, getDatatypeCoder, getEncoding, getEncodingFactory, getServerVersion, getServerVersionInformation, getSynchronizationObject, isAttached, removeExceptionListener, safelyDetach, setAttached, setDetached, setServerVersionclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, forceClose, getDatatypeCoder, getEncoding, getEncodingFactory, getServerVersion, getSynchronizationObject, isAttachedaddExceptionListener, removeExceptionListenertransactionStateChangedpublic static final int STATUS_VECTOR_SIZE
public static final int MAX_STATEMENT_LENGTH
protected final com.sun.jna.ptr.IntByReference handle
protected final ISC_STATUS[] statusVector
public JnaDatabase(JnaDatabaseConnection connection)
protected final FbClientLibrary getClientLibrary()
protected void checkConnected()
throws java.sql.SQLException
AbstractFbAttachmentSQLException if it isn't connected.checkConnected in class AbstractFbAttachment<JnaDatabaseConnection>java.sql.SQLExceptionprotected void internalDetach()
throws java.sql.SQLException
AbstractFbDatabase
Implementations of this method should only be called from AbstractFbDatabase.close(), and should not
notify database listeners of the database DatabaseListener.detaching(FbDatabase) and
DatabaseListener.detached(FbDatabase) events.
internalDetach in class AbstractFbDatabase<JnaDatabaseConnection>java.sql.SQLExceptionpublic void attach()
throws java.sql.SQLException
FbAttachmentattach in interface FbAttachmentjava.sql.SQLExceptionprotected void attachOrCreate(DatabaseParameterBuffer dpb, boolean create) throws java.sql.SQLException
java.sql.SQLExceptionprotected void afterAttachActions()
throws java.sql.SQLException
Implementation retrieves database information like dialect ODS and server version.
java.sql.SQLException - For errors reading or writing database information.public void createDatabase()
throws java.sql.SQLException
FbDatabasecreateDatabase in interface FbDatabasejava.sql.SQLExceptionpublic void dropDatabase()
throws java.sql.SQLException
FbDatabasedropDatabase in interface FbDatabasejava.sql.SQLExceptionpublic void cancelOperation(int kind)
throws java.sql.SQLException
FbDatabaseThe cancellation types are:
ISCConstants.fb_cancel_disableISCConstants.fb_cancel_enableISCConstants.fb_cancel_raiseISCConstants.fb_cancel_abortcancelOperation in interface FbDatabasekind - Cancellation typejava.sql.SQLException - For errors cancelling, or if the cancel operation is not supported.public JnaTransaction startTransaction(TransactionParameterBuffer tpb) throws java.sql.SQLException
FbDatabasestartTransaction in interface FbDatabasetpb - TransactionParameterBuffer with the required transaction
optionsjava.sql.SQLExceptionpublic FbTransaction reconnectTransaction(long transactionId) throws java.sql.SQLException
FbDatabaseReconnecting transactions is only allowed for transactions in limbo (prepared, but not committed or rolled back).
reconnectTransaction in interface FbDatabasetransactionId - The id of the transaction to reconnect.java.sql.SQLException - For errors reconnecting the transactionprotected byte[] getTransactionIdBuffer(long transactionId)
public JnaStatement createStatement(FbTransaction transaction) throws java.sql.SQLException
FbDatabasecreateStatement in interface FbDatabasetransaction - FbTransaction to associate with this statement (can be null).java.sql.SQLExceptionpublic FbBlob createBlobForOutput(FbTransaction transaction, BlobParameterBuffer blobParameterBuffer)
FbDatabaseThe blob is initially closed.
createBlobForOutput in interface FbDatabasetransaction - Transaction associated with the blob.blobParameterBuffer - Blob Parameter BufferFbBlobpublic FbBlob createBlobForInput(FbTransaction transaction, BlobParameterBuffer blobParameterBuffer, long blobId)
FbDatabaseThe blob is initially closed.
createBlobForInput in interface FbDatabasetransaction - Transaction associated with the blob.blobParameterBuffer - Blob Parameter BufferblobId - Handle id of the blobFbBlobpublic byte[] getDatabaseInfo(byte[] requestItems,
int maxBufferLength)
throws java.sql.SQLException
FbDatabasegetDatabaseInfo in interface FbDatabaserequestItems - Information items to requestmaxBufferLength - Maximum response buffer length to usemaxBufferLengthjava.sql.SQLException - For errors retrieving the information.public void executeImmediate(java.lang.String statementText,
FbTransaction transaction)
throws java.sql.SQLException
FbDatabase
A call to this method is the equivalent of a isc_dsql_execute_immediate() without parameters.
executeImmediate in interface FbDatabasestatementText - Statement texttransaction - Transaction (null only allowed if database is not attached!)java.sql.SQLException - For errors executing the statement, or if transaction is null when the
database is attached or not null when the database is not attachedpublic int getHandle()
getHandle in interface FbAttachmentgetHandle in interface FbDatabasepublic void setNetworkTimeout(int milliseconds)
throws java.sql.SQLException
FbAttachmentsetNetworkTimeout in interface FbAttachmentmilliseconds - Timeout in milliseconds; 0 means no timeout. If the attachment doesn't support milliseconds, it should
round up to the nearest second.java.sql.SQLException - If this attachment is closed, the value of milliseconds is smaller than 0, or if setting the
timeout fails.java.sql.SQLFeatureNotSupportedException - If this attachment doesn't support (changing) the network timeout.public int getNetworkTimeout()
throws java.sql.SQLException
FbAttachmentgetNetworkTimeout in interface FbAttachmentgetNetworkTimeout in class AbstractFbAttachment<JnaDatabaseConnection>java.sql.SQLException - If this attachment is closedjava.sql.SQLFeatureNotSupportedException - If this attachment doesn't support network timeoutpublic com.sun.jna.ptr.IntByReference getJnaHandle()
public final EncodingDefinition getEncodingDefinition()
protected JnaEventHandle validateEventHandle(EventHandle eventHandle) throws java.sql.SQLException
java.sql.SQLExceptionpublic JnaEventHandle createEventHandle(java.lang.String eventName, EventHandler eventHandler) throws java.sql.SQLException
FbDatabase
The returned event handle can be used with FbDatabase.queueEvent(org.firebirdsql.gds.EventHandle).
createEventHandle in interface FbDatabaseeventName - Name of the eventeventHandler - The event handler to call when the event occurredjava.sql.SQLException - For errors creating the event handlepublic void countEvents(EventHandle eventHandle) throws java.sql.SQLException
FbDatabasecountEvents in interface FbDatabaseeventHandle - The event handlejava.sql.SQLException - When the count can not be done (as - for example - the event handle is of the wrong type)public void queueEvent(EventHandle eventHandle) throws java.sql.SQLException
FbDatabasequeueEvent in interface FbDatabaseeventHandle - The event handle (created using FbDatabase.createEventHandle(String, EventHandler) of this instance).java.sql.SQLException - For errors establishing the asynchronous channel, or for queuing the event.public void cancelEvent(EventHandle eventHandle) throws java.sql.SQLException
FbDatabaseAfter cancellation, the event handle should be considered unusable. Before queueing a new event, an new handle needs to be created.
cancelEvent in interface FbDatabaseeventHandle - The event handle to canceljava.sql.SQLException - For errors cancelling the eventpublic void processStatusVector(ISC_STATUS[] statusVector, WarningMessageCallback warningMessageCallback) throws java.sql.SQLException
java.sql.SQLExceptionprotected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic boolean hasFeature(FbClientFeature clientFeature)
FbClientFeatureAccesshasFeature in interface FbClientFeatureAccessclientFeature - Client featuretrue if the feature is present, false otherwisepublic java.util.Set<FbClientFeature> getFeatures()
getFeatures in interface FbClientFeatureAccessCopyright © 2001-2021 Jaybird (Firebird JDBC/JCA) team. All rights reserved.