public class JnaDatabase extends AbstractFbDatabase<JnaDatabaseConnection> implements JnaAttachment, TransactionListener
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 |
connection, 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() |
int |
getHandle() |
com.sun.jna.ptr.IntByReference |
getJnaHandle() |
protected byte[] |
getTransactionIdBuffer(long transactionId) |
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.
|
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, transactionStateChanged
addExceptionListener, createDbCryptCallback, getDatatypeCoder, getEncoding, getEncodingFactory, getServerVersion, getServerVersionInformation, getSynchronizationObject, isAttached, removeExceptionListener, safelyDetach, setAttached, setDetached, setServerVersion
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, getDatatypeCoder, getEncoding, getEncodingFactory, getServerVersion, getSynchronizationObject, isAttached
addExceptionListener, removeExceptionListener
transactionStateChanged
public 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
AbstractFbAttachment
SQLException
if it isn't connected.checkConnected
in class AbstractFbAttachment<JnaDatabaseConnection>
java.sql.SQLException
protected 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.SQLException
public void attach() throws java.sql.SQLException
FbAttachment
attach
in interface FbAttachment
java.sql.SQLException
protected void attachOrCreate(DatabaseParameterBuffer dpb, boolean create) throws java.sql.SQLException
java.sql.SQLException
protected 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
FbDatabase
createDatabase
in interface FbDatabase
java.sql.SQLException
public void dropDatabase() throws java.sql.SQLException
FbDatabase
dropDatabase
in interface FbDatabase
java.sql.SQLException
public void cancelOperation(int kind) throws java.sql.SQLException
FbDatabase
The cancellation types are:
ISCConstants.fb_cancel_disable
ISCConstants.fb_cancel_enable
ISCConstants.fb_cancel_raise
ISCConstants.fb_cancel_abort
cancelOperation
in interface FbDatabase
kind
- Cancellation typejava.sql.SQLException
- For errors cancelling, or if the cancel operation is not supported.public JnaTransaction startTransaction(TransactionParameterBuffer tpb) throws java.sql.SQLException
FbDatabase
startTransaction
in interface FbDatabase
tpb
- TransactionParameterBuffer with the required transaction
optionsjava.sql.SQLException
public FbTransaction reconnectTransaction(long transactionId) throws java.sql.SQLException
FbDatabase
Reconnecting transactions is only allowed for transactions in limbo (prepared, but not committed or rolled back).
reconnectTransaction
in interface FbDatabase
transactionId
- 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
FbDatabase
createStatement
in interface FbDatabase
transaction
- FbTransaction to associate with this statement (can be null
).java.sql.SQLException
public FbBlob createBlobForOutput(FbTransaction transaction, BlobParameterBuffer blobParameterBuffer)
FbDatabase
The blob is initially closed.
createBlobForOutput
in interface FbDatabase
transaction
- Transaction associated with the blob.blobParameterBuffer
- Blob Parameter BufferFbBlob
public FbBlob createBlobForInput(FbTransaction transaction, BlobParameterBuffer blobParameterBuffer, long blobId)
FbDatabase
The blob is initially closed.
createBlobForInput
in interface FbDatabase
transaction
- Transaction associated with the blob.blobParameterBuffer
- Blob Parameter BufferblobId
- Handle id of the blobFbBlob
public byte[] getDatabaseInfo(byte[] requestItems, int maxBufferLength) throws java.sql.SQLException
FbDatabase
getDatabaseInfo
in interface FbDatabase
requestItems
- Information items to requestmaxBufferLength
- Maximum response buffer length to usemaxBufferLength
java.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 FbDatabase
statementText
- 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 FbAttachment
getHandle
in interface FbDatabase
public com.sun.jna.ptr.IntByReference getJnaHandle()
public final EncodingDefinition getEncodingDefinition()
protected JnaEventHandle validateEventHandle(EventHandle eventHandle) throws java.sql.SQLException
java.sql.SQLException
public 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 FbDatabase
eventName
- 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
FbDatabase
countEvents
in interface FbDatabase
eventHandle
- 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
FbDatabase
queueEvent
in interface FbDatabase
eventHandle
- 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
FbDatabase
After cancellation, the event handle should be considered unusable. Before queueing a new event, an new handle needs to be created.
cancelEvent
in interface FbDatabase
eventHandle
- 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.SQLException
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
Copyright © 2001-2021 Jaybird (Firebird JDBC/JCA) team. All rights reserved.