public abstract class AbstractFbAttachment<T extends AbstractConnection<? extends IAttachProperties<?>,? extends FbAttachment>> extends java.lang.Object implements FbAttachment
AbstractFbService
and AbstractFbDatabase
.Modifier and Type | Field and Description |
---|---|
protected T |
connection |
protected ExceptionListenerDispatcher |
exceptionListenerDispatcher |
Modifier | Constructor and Description |
---|---|
protected |
AbstractFbAttachment(T connection,
DatatypeCoder datatypeCoder) |
Modifier and Type | Method and Description |
---|---|
void |
addExceptionListener(ExceptionListener listener)
Adds an exception listener to this object.
|
protected abstract void |
checkConnected()
Checks if the attachment is connected, and throws a
SQLException if it isn't connected. |
void |
forceClose()
Forces the connection to close without proper detach or cleanup.
|
DatatypeCoder |
getDatatypeCoder() |
Encoding |
getEncoding() |
IEncodingFactory |
getEncodingFactory() |
int |
getNetworkTimeout()
Gets the current network timeout for this attachment.
|
GDSServerVersion |
getServerVersion() |
protected org.firebirdsql.gds.ng.ServerVersionInformation |
getServerVersionInformation() |
boolean |
isAttached()
Current attachment status.
|
boolean |
isLockedByCurrentThread()
Queries if the lock is held by the current thread.
|
void |
removeExceptionListener(ExceptionListener listener)
Removes an exception listener to this object.
|
protected void |
safelyDetach()
Performs
FbAttachment.close() suppressing any exception. |
protected void |
setAttached()
Called when this attachment is attached.
|
protected void |
setDetached()
Called when this attachment is detached.
|
protected void |
setServerVersion(java.lang.String... versionStrings)
Sets the Firebird version from one or more version string elements.
|
LockCloseable |
withLock()
Locks the lock with
Lock.lock() (or equivalent). |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
attach, close, getHandle, setNetworkTimeout
protected final ExceptionListenerDispatcher exceptionListenerDispatcher
protected final T extends AbstractConnection<? extends IAttachProperties<?>,? extends FbAttachment> connection
protected AbstractFbAttachment(T connection, DatatypeCoder datatypeCoder)
public final LockCloseable withLock()
FbAttachment
Lock.lock()
(or equivalent).
The returned LockClosable
can be used to unlock, preferably for use in a try-with-resources.
withLock
in interface FbAttachment
public final boolean isLockedByCurrentThread()
FbAttachment
isLockedByCurrentThread
in interface FbAttachment
true
if current thread holds this lock and false
otherwiseReentrantLock.isHeldByCurrentThread()
public void forceClose() throws java.sql.SQLException
If a given implementation does not support this, then this method should call FbAttachment.close()
.
Default implementation, calls FbAttachment.close()
forceClose
in interface FbAttachment
java.sql.SQLException
- For problems closing the connection.public GDSServerVersion getServerVersion()
getServerVersion
in interface FbAttachment
protected final void setServerVersion(java.lang.String... versionStrings)
This method should only be called by this instance.
versionStrings
- Raw version stringsprotected org.firebirdsql.gds.ng.ServerVersionInformation getServerVersionInformation()
protected final void setAttached()
Only this AbstractFbDatabase
instance should call this method.
public boolean isAttached()
FbAttachment
isAttached
in interface FbAttachment
true
if connected to the server and attached to a database or service, false
otherwise.protected final void setDetached()
Only this AbstractFbAttachment
instance should call this method.
public final IEncodingFactory getEncodingFactory()
getEncodingFactory
in interface FbAttachment
IEncodingFactory
for this connectionpublic final Encoding getEncoding()
getEncoding
in interface FbAttachment
IEncodingFactory.getDefaultEncoding()
on the result of FbAttachment.getEncodingFactory()
).public final DatatypeCoder getDatatypeCoder()
getDatatypeCoder
in interface FbAttachment
DatatypeCoder
for this database implementation.public int getNetworkTimeout() throws java.sql.SQLException
FbAttachment
getNetworkTimeout
in interface FbAttachment
java.sql.SQLException
- If this attachment is closedjava.sql.SQLFeatureNotSupportedException
- If this attachment doesn't support network timeoutpublic final void addExceptionListener(ExceptionListener listener)
ExceptionListenable
Implementations use WeakReference
.
addExceptionListener
in interface ExceptionListenable
listener
- Listener to registerpublic final void removeExceptionListener(ExceptionListener listener)
ExceptionListenable
removeExceptionListener
in interface ExceptionListenable
listener
- Listener to removeprotected abstract void checkConnected() throws java.sql.SQLException
SQLException
if it isn't connected.java.sql.SQLException
protected final void safelyDetach()
FbAttachment.close()
suppressing any exception.Copyright © 2001-2023 Jaybird (Firebird JDBC) team. All rights reserved.