Class JnaDatabase

java.lang.Object
org.firebirdsql.gds.ng.AbstractFbAttachment<T>
org.firebirdsql.gds.ng.AbstractFbDatabase<JnaDatabaseConnection>
org.firebirdsql.gds.ng.jna.JnaDatabase
All Implemented Interfaces:
AutoCloseable, org.firebirdsql.gds.ng.FbAttachment, org.firebirdsql.gds.ng.FbDatabase, FbClientFeatureAccess, JnaAttachment, org.firebirdsql.gds.ng.listeners.ExceptionListenable, org.firebirdsql.gds.ng.listeners.TransactionListener

public class JnaDatabase extends org.firebirdsql.gds.ng.AbstractFbDatabase<JnaDatabaseConnection> implements JnaAttachment, org.firebirdsql.gds.ng.listeners.TransactionListener, FbClientFeatureAccess
Implementation of FbDatabase for native client access.
Since:
3.0
Author:
Mark Rotteveel
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final com.sun.jna.ptr.IntByReference
     
    static final int
     
    static final int
     
    protected final ISC_STATUS[]
     

    Fields inherited from class org.firebirdsql.gds.ng.AbstractFbDatabase

    databaseListenerDispatcher

    Fields inherited from class org.firebirdsql.gds.ng.AbstractFbAttachment

    connection, exceptionListenerDispatcher
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Additional tasks to execute directly after attach operation.
    void
     
    protected void
    attachOrCreate(org.firebirdsql.gds.DatabaseParameterBuffer dpb, boolean create)
     
    void
    cancelEvent(org.firebirdsql.gds.EventHandle eventHandle)
     
    void
    cancelOperation(int kind)
     
    protected void
     
    void
    countEvents(org.firebirdsql.gds.EventHandle eventHandle)
     
    org.firebirdsql.gds.ng.FbBlob
    createBlobForInput(org.firebirdsql.gds.ng.FbTransaction transaction, org.firebirdsql.gds.BlobParameterBuffer blobParameterBuffer, long blobId)
     
    org.firebirdsql.gds.ng.FbBlob
    createBlobForOutput(org.firebirdsql.gds.ng.FbTransaction transaction, org.firebirdsql.gds.BlobParameterBuffer blobParameterBuffer)
     
    void
     
    createEventHandle(String eventName, org.firebirdsql.gds.EventHandler eventHandler)
     
    createStatement(org.firebirdsql.gds.ng.FbTransaction transaction)
     
    void
     
    void
    executeImmediate(String statementText, org.firebirdsql.gds.ng.FbTransaction transaction)
     
    protected final FbClientLibrary
     
    byte[]
    getDatabaseInfo(byte[] requestItems, int maxBufferLength)
     
     
    int
     
    com.sun.jna.ptr.IntByReference
     
    int
     
    boolean
    hasFeature(FbClientFeature clientFeature)
    Checks for presence of a client feature.
    protected void
     
    void
    processStatusVector(ISC_STATUS[] statusVector, org.firebirdsql.gds.ng.WarningMessageCallback warningMessageCallback)
     
    void
    queueEvent(org.firebirdsql.gds.EventHandle eventHandle)
     
    org.firebirdsql.gds.ng.FbTransaction
    reconnectTransaction(long transactionId)
     
    protected void
     
    void
    setNetworkTimeout(int milliseconds)
     
    org.firebirdsql.gds.ng.FbTransaction
    startTransaction(String statementText)
     
    startTransaction(org.firebirdsql.gds.TransactionParameterBuffer tpb)
     
    protected JnaEventHandle
    validateEventHandle(org.firebirdsql.gds.EventHandle eventHandle)
     

    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, forceClose, getDatatypeCoder, getEncoding, getEncodingFactory, getServerVersion, isAttached, 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, getServerVersion, isAttached, isLockedByCurrentThread, withLock

    Methods inherited from interface org.firebirdsql.gds.ng.FbDatabase

    createBlobForInput, createBlobForInput, createBlobForOutput, createBlobForOutput

    Methods inherited from interface org.firebirdsql.gds.ng.listeners.TransactionListener

    transactionStateChanged
  • Field Details

    • STATUS_VECTOR_SIZE

      public static final int STATUS_VECTOR_SIZE
      See Also:
    • MAX_STATEMENT_LENGTH

      public static final int MAX_STATEMENT_LENGTH
      See Also:
    • handle

      protected final com.sun.jna.ptr.IntByReference handle
    • statusVector

      protected final ISC_STATUS[] statusVector
  • Constructor Details

  • Method Details

    • getClientLibrary

      protected final FbClientLibrary getClientLibrary()
      Returns:
      The client library instance associated with the database.
    • setDetachedJna

      protected void setDetachedJna()
    • checkConnected

      protected void checkConnected() throws SQLException
      Specified by:
      checkConnected in class org.firebirdsql.gds.ng.AbstractFbAttachment<JnaDatabaseConnection>
      Throws:
      SQLException
    • internalDetach

      protected void internalDetach() throws SQLException
      Specified by:
      internalDetach in class org.firebirdsql.gds.ng.AbstractFbDatabase<JnaDatabaseConnection>
      Throws:
      SQLException
    • attach

      public void attach() throws SQLException
      Specified by:
      attach in interface org.firebirdsql.gds.ng.FbAttachment
      Throws:
      SQLException
    • attachOrCreate

      protected void attachOrCreate(org.firebirdsql.gds.DatabaseParameterBuffer dpb, boolean create) throws SQLException
      Throws:
      SQLException
    • afterAttachActions

      protected void afterAttachActions() throws SQLException
      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.
    • createDatabase

      public void createDatabase() throws SQLException
      Specified by:
      createDatabase in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • dropDatabase

      public void dropDatabase() throws SQLException
      Specified by:
      dropDatabase in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • cancelOperation

      public void cancelOperation(int kind) throws SQLException
      Specified by:
      cancelOperation in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • startTransaction

      public JnaTransaction startTransaction(org.firebirdsql.gds.TransactionParameterBuffer tpb) throws SQLException
      Specified by:
      startTransaction in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • startTransaction

      public org.firebirdsql.gds.ng.FbTransaction startTransaction(String statementText) throws SQLException
      Specified by:
      startTransaction in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • reconnectTransaction

      public org.firebirdsql.gds.ng.FbTransaction reconnectTransaction(long transactionId) throws SQLException
      Specified by:
      reconnectTransaction in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • createStatement

      public JnaStatement createStatement(org.firebirdsql.gds.ng.FbTransaction transaction) throws SQLException
      Specified by:
      createStatement in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • createBlobForOutput

      public org.firebirdsql.gds.ng.FbBlob createBlobForOutput(org.firebirdsql.gds.ng.FbTransaction transaction, org.firebirdsql.gds.BlobParameterBuffer blobParameterBuffer)
      Specified by:
      createBlobForOutput in interface org.firebirdsql.gds.ng.FbDatabase
    • createBlobForInput

      public org.firebirdsql.gds.ng.FbBlob createBlobForInput(org.firebirdsql.gds.ng.FbTransaction transaction, org.firebirdsql.gds.BlobParameterBuffer blobParameterBuffer, long blobId)
      Specified by:
      createBlobForInput in interface org.firebirdsql.gds.ng.FbDatabase
    • getDatabaseInfo

      public byte[] getDatabaseInfo(byte[] requestItems, int maxBufferLength) throws SQLException
      Specified by:
      getDatabaseInfo in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • executeImmediate

      public void executeImmediate(String statementText, org.firebirdsql.gds.ng.FbTransaction transaction) throws SQLException
      Specified by:
      executeImmediate in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • getHandle

      public int getHandle()
      Specified by:
      getHandle in interface org.firebirdsql.gds.ng.FbAttachment
      Specified by:
      getHandle in interface org.firebirdsql.gds.ng.FbDatabase
    • setNetworkTimeout

      public void setNetworkTimeout(int milliseconds) throws SQLException
      Specified by:
      setNetworkTimeout in interface org.firebirdsql.gds.ng.FbAttachment
      Throws:
      SQLException
    • getNetworkTimeout

      public int getNetworkTimeout() throws SQLException
      Specified by:
      getNetworkTimeout in interface org.firebirdsql.gds.ng.FbAttachment
      Overrides:
      getNetworkTimeout in class org.firebirdsql.gds.ng.AbstractFbAttachment<JnaDatabaseConnection>
      Throws:
      SQLException
    • getJnaHandle

      public com.sun.jna.ptr.IntByReference getJnaHandle()
    • validateEventHandle

      protected JnaEventHandle validateEventHandle(org.firebirdsql.gds.EventHandle eventHandle) throws SQLException
      Throws:
      SQLException
    • createEventHandle

      public JnaEventHandle createEventHandle(String eventName, org.firebirdsql.gds.EventHandler eventHandler) throws SQLException
      Specified by:
      createEventHandle in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • countEvents

      public void countEvents(org.firebirdsql.gds.EventHandle eventHandle) throws SQLException
      Specified by:
      countEvents in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • queueEvent

      public void queueEvent(org.firebirdsql.gds.EventHandle eventHandle) throws SQLException
      Specified by:
      queueEvent in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • cancelEvent

      public void cancelEvent(org.firebirdsql.gds.EventHandle eventHandle) throws SQLException
      Specified by:
      cancelEvent in interface org.firebirdsql.gds.ng.FbDatabase
      Throws:
      SQLException
    • processStatusVector

      public void processStatusVector(ISC_STATUS[] statusVector, org.firebirdsql.gds.ng.WarningMessageCallback warningMessageCallback) throws SQLException
      Throws:
      SQLException
    • hasFeature

      public boolean hasFeature(FbClientFeature clientFeature)
      Description copied from interface: FbClientFeatureAccess
      Checks for presence of a client feature.
      Specified by:
      hasFeature in interface FbClientFeatureAccess
      Parameters:
      clientFeature - Client feature
      Returns:
      true if the feature is present, false otherwise
    • getFeatures

      public Set<FbClientFeature> getFeatures()
      Specified by:
      getFeatures in interface FbClientFeatureAccess
      Returns:
      an unmodifiable set with supported client features