Package org.firebirdsql.gds.ng.jna

## Class JnaService

- java.lang.Object
- - org.firebirdsql.gds.ng.AbstractFbAttachment<T>
  - - org.firebirdsql.gds.ng.AbstractFbService<JnaServiceConnection>
    - - org.firebirdsql.gds.ng.jna.JnaService

- All Implemented Interfaces:
    `java.lang.AutoCloseable`, `FbAttachment`, `FbService`, `JnaAttachment`, `ExceptionListenable`

      public final class JnaService
      extends AbstractFbService<JnaServiceConnection>
      implements JnaAttachment

  Implementation of `FbService` for native client access.
  Since:
    3.0
  Author:
    Mark Rotteveel

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static int` | `STATUS_VECTOR_SIZE` |

    - ### Fields inherited from class org.firebirdsql.gds.ng.AbstractFbService

      `serviceListenerDispatcher`

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

      `connection, exceptionListenerDispatcher`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `JnaService​(JnaServiceConnection connection)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `afterAttachActions()` | Additional tasks to execute directly after attach operation.
    `void` | `attach()` | Attach to the attachment type.
    `protected void` | `checkConnected()` | Checks if the attachment is connected, and throws a `SQLException` if it isn't connected.
    `ServiceParameterBuffer` | `createServiceParameterBuffer()` | Creates an empty `ServiceParameterBuffer`.
    `ServiceRequestBuffer` | `createServiceRequestBuffer()` |
    `protected void` | `finalize()` |
    `int` | `getHandle()` |
    `com.sun.jna.ptr.IntByReference` | `getJnaHandle()` |
    `int` | `getNetworkTimeout()` | Gets the current network timeout for this attachment.
    `byte[]` | `getServiceInfo​(ServiceParameterBuffer serviceParameterBuffer, ServiceRequestBuffer serviceRequestBuffer, int maxBufferLength)` | Performs a service info request (service query.
    `protected void` | `internalDetach()` | Actual implementation of service detach.
    `void` | `processStatusVector​(ISC_STATUS[] statusVector, WarningMessageCallback warningMessageCallback)` |
    `void` | `setNetworkTimeout​(int milliseconds)` | Sets the network timeout for this attachment.
    `void` | `startServiceAction​(ServiceRequestBuffer serviceRequestBuffer)` | Starts a service action.

    - ### Methods inherited from class org.firebirdsql.gds.ng.AbstractFbService

      `addServiceListener, close, getDescribeServiceRequestBuffer, getServiceInfo, getServiceInformationProcessor, getServiceWarningCallback, removeServiceListener`

    - ### Methods inherited from class org.firebirdsql.gds.ng.AbstractFbAttachment

      `addExceptionListener, forceClose, getDatatypeCoder, getEncoding, getEncodingFactory, getServerVersion, getServerVersionInformation, getSynchronizationObject, isAttached, 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, getServerVersion, getSynchronizationObject, isAttached`

- - ### Field Detail

    - #### STATUS_VECTOR_SIZE

          public static final int STATUS_VECTOR_SIZE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### JnaService

          public JnaService​(JnaServiceConnection connection)

  - ### Method Detail

    - #### createServiceParameterBuffer

          public ServiceParameterBuffer createServiceParameterBuffer()

      Description copied from interface: `FbService`
      Creates an empty `ServiceParameterBuffer`.

      Attach expects a service parameter buffer to have the version as the first item. This needs to be added explicitly.

      Specified by:
        `createServiceParameterBuffer` in interface `FbService`
      Returns:
        Service

    - #### createServiceRequestBuffer

          public ServiceRequestBuffer createServiceRequestBuffer()

      Specified by:
        `createServiceRequestBuffer` in interface `FbService`
      Returns:
        An empty service request buffer

    - #### checkConnected

          protected void checkConnected()
                                 throws java.sql.SQLException

      Description copied from class: `AbstractFbAttachment`
      Checks if the attachment is connected, and throws a `SQLException` if it isn't connected.
      Specified by:
        `checkConnected` in class `AbstractFbAttachment<JnaServiceConnection>`
      Throws:
        `java.sql.SQLException`

    - #### getServiceInfo

          public byte[] getServiceInfo​(ServiceParameterBuffer serviceParameterBuffer,
                                       ServiceRequestBuffer serviceRequestBuffer,
                                       int maxBufferLength)
                                throws java.sql.SQLException

      Description copied from interface: `FbService`
      Performs a service info request (service query.
      Specified by:
        `getServiceInfo` in interface `FbService`
      Parameters:
        `serviceParameterBuffer` - Service parameters (can be null)
        `serviceRequestBuffer` - Service request info
        `maxBufferLength` - 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.

    - #### startServiceAction

          public void startServiceAction​(ServiceRequestBuffer serviceRequestBuffer)
                                  throws java.sql.SQLException

      Description copied from interface: `FbService`
      Starts a service action.
      Specified by:
        `startServiceAction` in interface `FbService`
      Parameters:
        `serviceRequestBuffer` - Service action request details
      Throws:
        `java.sql.SQLException` - For errors starting the service action.

    - #### attach

          public void attach()
                      throws java.sql.SQLException

      Description copied from interface: `FbAttachment`
      Attach to the attachment type.
      Specified by:
        `attach` in interface `FbAttachment`
      Throws:
        `java.sql.SQLException`

    - #### afterAttachActions

          protected void afterAttachActions()
                                     throws java.sql.SQLException

      Additional tasks to execute directly after attach operation.

      Implementation retrieves service information like server version.

      Throws:
        `java.sql.SQLException` - For errors reading or writing database information.

    - #### internalDetach

          protected void internalDetach()
                                 throws java.sql.SQLException

      Description copied from class: `AbstractFbService`
      Actual implementation of service detach.

      Implementations of this method should only be called from `AbstractFbService.close()`, and should not notify service listeners of the service `ServiceListener.detaching(FbService)` and `ServiceListener.detached(FbService)` events.

      Specified by:
        `internalDetach` in class `AbstractFbService<JnaServiceConnection>`
      Throws:
        `java.sql.SQLException`

    - #### getHandle

          public int getHandle()

      Specified by:
        `getHandle` in interface `FbAttachment`
      Specified by:
        `getHandle` in interface `FbService`
      Returns:
        The attachment handle value

    - #### getJnaHandle

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

    - #### setNetworkTimeout

          public void setNetworkTimeout​(int milliseconds)
                                 throws java.sql.SQLException

      Description copied from interface: `FbAttachment`
      Sets the network timeout for this attachment.
      Specified by:
        `setNetworkTimeout` in interface `FbAttachment`
      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:
        `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.

    - #### getNetworkTimeout

          public int getNetworkTimeout()
                                throws java.sql.SQLException

      Description copied from interface: `FbAttachment`
      Gets the current network timeout for this attachment.
      Specified by:
        `getNetworkTimeout` in interface `FbAttachment`
      Overrides:
        `getNetworkTimeout` in class `AbstractFbAttachment<JnaServiceConnection>`
      Returns:
        Timeout in milliseconds, 0 means no timeout
      Throws:
        `java.sql.SQLException` - If this attachment is closed
        `java.sql.SQLFeatureNotSupportedException` - If this attachment doesn't support network timeout

    - #### processStatusVector

          public void processStatusVector​(ISC_STATUS[] statusVector,
                                          WarningMessageCallback warningMessageCallback)
                                   throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### finalize

          protected void finalize()
                           throws java.lang.Throwable

      Overrides:
        `finalize` in class `java.lang.Object`
      Throws:
        `java.lang.Throwable`