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 ofFbServicefor native client access.- Since:
- 3.0
- Author:
- Mark Rotteveel
-
-
Field Summary
Fields Modifier and Type Field Description static intSTATUS_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 voidafterAttachActions()Additional tasks to execute directly after attach operation.voidattach()Attach to the attachment type.protected voidcheckConnected()Checks if the attachment is connected, and throws aSQLExceptionif it isn't connected.ServiceParameterBuffercreateServiceParameterBuffer()Creates an emptyServiceParameterBuffer.ServiceRequestBuffercreateServiceRequestBuffer()protected voidfinalize()intgetHandle()com.sun.jna.ptr.IntByReferencegetJnaHandle()intgetNetworkTimeout()Gets the current network timeout for this attachment.byte[]getServiceInfo(ServiceParameterBuffer serviceParameterBuffer, ServiceRequestBuffer serviceRequestBuffer, int maxBufferLength)Performs a service info request (service query.protected voidinternalDetach()Actual implementation of service detach.voidprocessStatusVector(ISC_STATUS[] statusVector, WarningMessageCallback warningMessageCallback)voidsetNetworkTimeout(int milliseconds)Sets the network timeout for this attachment.voidstartServiceAction(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:FbServiceCreates an emptyServiceParameterBuffer.Attach expects a service parameter buffer to have the version as the first item. This needs to be added explicitly.
- Specified by:
createServiceParameterBufferin interfaceFbService- Returns:
- Service
-
createServiceRequestBuffer
public ServiceRequestBuffer createServiceRequestBuffer()
- Specified by:
createServiceRequestBufferin interfaceFbService- Returns:
- An empty service request buffer
-
checkConnected
protected void checkConnected() throws java.sql.SQLExceptionDescription copied from class:AbstractFbAttachmentChecks if the attachment is connected, and throws aSQLExceptionif it isn't connected.- Specified by:
checkConnectedin classAbstractFbAttachment<JnaServiceConnection>- Throws:
java.sql.SQLException
-
getServiceInfo
public byte[] getServiceInfo(ServiceParameterBuffer serviceParameterBuffer, ServiceRequestBuffer serviceRequestBuffer, int maxBufferLength) throws java.sql.SQLException
Description copied from interface:FbServicePerforms a service info request (service query.- Specified by:
getServiceInfoin interfaceFbService- Parameters:
serviceParameterBuffer- Service parameters (can be null)serviceRequestBuffer- Service request infomaxBufferLength- 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:FbServiceStarts a service action.- Specified by:
startServiceActionin interfaceFbService- Parameters:
serviceRequestBuffer- Service action request details- Throws:
java.sql.SQLException- For errors starting the service action.
-
attach
public void attach() throws java.sql.SQLExceptionDescription copied from interface:FbAttachmentAttach to the attachment type.- Specified by:
attachin interfaceFbAttachment- Throws:
java.sql.SQLException
-
afterAttachActions
protected void afterAttachActions() throws java.sql.SQLExceptionAdditional 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.SQLExceptionDescription copied from class:AbstractFbServiceActual implementation of service detach.Implementations of this method should only be called from
AbstractFbService.close(), and should not notify service listeners of the serviceServiceListener.detaching(FbService)andServiceListener.detached(FbService)events.- Specified by:
internalDetachin classAbstractFbService<JnaServiceConnection>- Throws:
java.sql.SQLException
-
getHandle
public int getHandle()
- Specified by:
getHandlein interfaceFbAttachment- Specified by:
getHandlein interfaceFbService- Returns:
- The attachment handle value
-
getJnaHandle
public com.sun.jna.ptr.IntByReference getJnaHandle()
-
setNetworkTimeout
public void setNetworkTimeout(int milliseconds) throws java.sql.SQLExceptionDescription 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:
java.sql.SQLException- If this attachment is closed, the value ofmillisecondsis 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.SQLExceptionDescription copied from interface:FbAttachmentGets the current network timeout for this attachment.- Specified by:
getNetworkTimeoutin interfaceFbAttachment- Overrides:
getNetworkTimeoutin classAbstractFbAttachment<JnaServiceConnection>- Returns:
- Timeout in milliseconds, 0 means no timeout
- Throws:
java.sql.SQLException- If this attachment is closedjava.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:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
-