Skip to content

Commit 2ec431f

Browse files
committed
#954 Use checkAttached instead of checkConnected
1 parent e44b13a commit 2ec431f

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

jaybird-native/src/main/java/org/firebirdsql/gds/ng/jna/JnaDatabase.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public void createDatabase() throws SQLException {
173173
@Override
174174
public void dropDatabase() throws SQLException {
175175
try {
176-
checkConnected();
176+
checkAttached();
177177
try (LockCloseable ignored = withLock()) {
178178
try {
179179
clientLibrary.isc_drop_database(statusVector, handle);
@@ -211,7 +211,7 @@ public void cancelOperation(int kind) throws SQLException {
211211
@Override
212212
public JnaTransaction startTransaction(final TransactionParameterBuffer tpb) throws SQLException {
213213
try {
214-
checkConnected();
214+
checkAttached();
215215
var transactionHandle = new IntByReference(0);
216216
byte[] tpbArray = tpb.toBytesWithType();
217217
try (LockCloseable ignored = withLock()) {
@@ -232,7 +232,7 @@ public JnaTransaction startTransaction(final TransactionParameterBuffer tpb) thr
232232
@Override
233233
public FbTransaction startTransaction(String statementText) throws SQLException {
234234
try {
235-
checkConnected();
235+
checkAttached();
236236
var transactionHandle = new IntByReference(0);
237237
byte[] statementArray = getEncoding().encodeToCharset(statementText);
238238
try (LockCloseable ignored = withLock()) {
@@ -253,7 +253,7 @@ public FbTransaction startTransaction(String statementText) throws SQLException
253253
@Override
254254
public FbTransaction reconnectTransaction(long transactionId) throws SQLException {
255255
try {
256-
checkConnected();
256+
checkAttached();
257257
final byte[] transactionIdBuffer = getTransactionIdBuffer(transactionId);
258258

259259
final IntByReference transactionHandle = new IntByReference(0);
@@ -276,7 +276,7 @@ public FbTransaction reconnectTransaction(long transactionId) throws SQLExceptio
276276
@Override
277277
public JnaStatement createStatement(@Nullable FbTransaction transaction) throws SQLException {
278278
try {
279-
checkConnected();
279+
checkAttached();
280280
final JnaStatement stmt = new JnaStatement(this);
281281
stmt.addExceptionListener(exceptionListenerDispatcher);
282282
stmt.setTransaction(transaction);
@@ -423,7 +423,7 @@ public void countEvents(EventHandle eventHandle) throws SQLException {
423423
@Override
424424
public void queueEvent(EventHandle eventHandle) throws SQLException {
425425
try {
426-
checkConnected();
426+
checkAttached();
427427
final JnaEventHandle jnaEventHandle = validateEventHandle(eventHandle);
428428

429429
try (LockCloseable ignored = withLock()) {
@@ -451,7 +451,7 @@ public void queueEvent(EventHandle eventHandle) throws SQLException {
451451
@Override
452452
public void cancelEvent(EventHandle eventHandle) throws SQLException {
453453
try {
454-
checkConnected();
454+
checkAttached();
455455
final JnaEventHandle jnaEventHandle = validateEventHandle(eventHandle);
456456

457457
try (LockCloseable ignored = withLock()) {

src/main/org/firebirdsql/gds/ng/AbstractFbAttachment.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,20 +150,25 @@ public final void removeExceptionListener(ExceptionListener listener) {
150150
/**
151151
* Checks if the attachment is connected, and throws a {@link SQLException} if it isn't connected.
152152
* <p>
153-
* Implementations where connected and attached are indistinguishable may call {@link #checkAttached()} or
154-
* vice versa.
153+
* In general, {@link #checkAttached()} should be used. An attachment might be connected (e.g. TCP/IP connection
154+
* established to the server), but not (yet) attached to a database or service.
155155
* </p>
156+
*
157+
* @see #checkAttached()
156158
*/
157159
protected abstract void checkConnected() throws SQLException;
158160

159161
/**
160-
* Returns if this attachment is connected as checked by {@link #checkConnected()}.
162+
* Returns {@code true} if this attachment is connected as checked by {@link #checkConnected()}.
161163
* <p>
162164
* In general, {@link #isAttached()} should be used. An attachment might be connected (e.g. TCP/IP connection
163165
* established to the server), but not (yet) attached to a database or service.
164166
* </p>
165167
*
166168
* @return {@code true} if connected
169+
* @see #isAttached()
170+
* @see #checkAttached()
171+
* @see #checkConnected()
167172
* @since 7
168173
*/
169174
protected abstract boolean isConnected();

0 commit comments

Comments
 (0)