Module org.firebirdsql.jaybird
Package org.firebirdsql.jdbc

# Class AbstractStatement

java.lang.Object
org.firebirdsql.jdbc.AbstractStatement

All Implemented Interfaces:
  `AutoCloseable`, `Statement`, `Wrapper`, `FirebirdStatement`

Direct Known Subclasses:
  `FBStatement`

@InternalApi @NullMarked public abstract class AbstractStatement extends Object implements Statement, FirebirdStatement
Common abstract base class for statement implementations.

This class is internal API of Jaybird. Future versions may radically change, move, or make inaccessible this type. For the public API, refer to the `Statement` and `FirebirdStatement` interfaces.

Since:
  6
Author:
  Mark Rotteveel

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final FBConnection`
`connection`

### Fields inherited from interface java.sql.Statement

`CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`AbstractStatement(FBConnection connection, ResultSetBehavior resultSetBehavior)`

## Method Summary

Modifier and Type
Method
Description
`protected final void`
`addWarning(SQLWarning warning)`
`protected final void`
`checkValidity()`
Check if this statement is valid (not closed).
`final void`
`clearWarnings()`
`void`
`close()`
`final void`
`closeOnCompletion()`
`final void`
`completeStatement()`
Completes this statement with `CompletionReason.OTHER`.
`abstract void`
`completeStatement(CompletionReason reason)`
Completes this statement with `reason`.
`final boolean`
`equals(Object other)`
`protected final FetchConfig`
`fetchConfig()`
`final FBConnection`
`getConnection()`
`protected final @Nullable String`
`getCursorName()`
`final int`
`getFetchDirection()`
`final int`
`getFetchSize()`
`final long`
`getLargeMaxRows()`
`final int`
`getLocalStatementId()`
The local statement id is intended to identify the statement for internal implementation purposes.
`final int`
`getMaxRows()`
`final int`
`getResultSetConcurrency()`
`final int`
`getResultSetHoldability()`
`final int`
`getResultSetType()`
`protected abstract FbStatement`
`getStatementHandle()`
`abstract int`
`getStatementType()`
Get the current statement type of this statement.
`final @Nullable SQLWarning`
`getWarnings()`
`final int`
`hashCode()`
`final boolean`
`isClosed()`
`final boolean`
`isCloseOnCompletion()`
`final boolean`
`isPoolable()`
`boolean`
`isValid()`
Check if this statement is valid.
`protected final void`
`performCloseOnCompletion()`
Closes this statement if `closeOnCompletion` is set to `true`, does nothing if set to `false`.
`protected final ResultSetBehavior`
`resultSetBehavior()`
`final void`
`setCursorName(@Nullable String cursorName)`
`final void`
`setFetchDirection(int direction)`
`final void`
`setFetchSize(int rows)`
`final void`
`setLargeMaxRows(long max)`
`final void`
`setMaxRows(int max)`
`final void`
`setPoolable(boolean poolable)`
`protected final LockCloseable`
`withLock()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.firebirdsql.jdbc.FirebirdStatement

`getCurrentResultSet, getDeletedRowsCount, getExecutionPlan, getExplainedExecutionPlan, getInsertedRowsCount, getLastExecutionPlan, getLastExplainedExecutionPlan, getUpdatedRowsCount, hasOpenResultSet`

### Methods inherited from interface java.sql.Statement

`addBatch, cancel, clearBatch, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, execute, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getGeneratedKeys, getLargeUpdateCount, getMaxFieldSize, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getUpdateCount, isSimpleIdentifier, setEscapeProcessing, setMaxFieldSize, setQueryTimeout`

### Methods inherited from interface java.sql.Wrapper

`isWrapperFor, unwrap`

## Field Details

### connection

protected final FBConnection connection

## Constructor Details

### AbstractStatement

protected AbstractStatement(FBConnection connection, ResultSetBehavior resultSetBehavior)

## Method Details

### getConnection

public final FBConnection getConnection() throws SQLException

Specified by:
  `getConnection` in interface `Statement`
Throws:
  `SQLException`

### getStatementHandle

protected abstract FbStatement getStatementHandle() throws SQLException

Returns:
  instance of `FbStatement` associated with this statement; cannot be `null`
Throws:
  `SQLException` - if this statement is closed
  `SQLFeatureNotSupportedException` - if this statement implementation does not use statement handles

### getStatementType

public abstract int getStatementType()
Get the current statement type of this statement.

The returned value is one of the `TYPE_*` constant values defined in `FirebirdPreparedStatement`, or `0` if the statement currently does not have a statement type.

Returns:
  The identifier for the given statement's type

### close

public void close() throws SQLException

Subclasses overriding this method are expected to call this method with `super.close()` at an appropriate point to mark it closed.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Statement`
Throws:
  `SQLException`

### isClosed

public final boolean isClosed()

Specified by:
  `isClosed` in interface `Statement`

### isValid

public boolean isValid()
Description copied from interface: `FirebirdStatement`
Check if this statement is valid.

Specified by:
  `isValid` in interface `FirebirdStatement`
Returns:
  `true` if statement is valid and can be used to execute SQL.

### checkValidity

protected final void checkValidity() throws SQLException
Check if this statement is valid (not closed). This method should be invoked before executing any action which requires a valid/open statement.

Throws:
  `SQLException` - if this Statement has been closed and cannot be used anymore.

### completeStatement

public final void completeStatement() throws SQLException
Completes this statement with `CompletionReason.OTHER`.

Throws:
  `SQLException` - for failures completing this statement
See Also:
  - `completeStatement(CompletionReason)`

### completeStatement

public abstract void completeStatement(CompletionReason reason) throws SQLException
Completes this statement with `reason`.

On completion, any open result set will be closed, and possibly the statement itself may be closed.

Parameters:
  `reason` - completion reason
Throws:
  `SQLException` - for failures completing this statement

### isPoolable

public final boolean isPoolable() throws SQLException

Specified by:
  `isPoolable` in interface `Statement`
Throws:
  `SQLException`

### setPoolable

public final void setPoolable(boolean poolable) throws SQLException

Specified by:
  `setPoolable` in interface `Statement`
Throws:
  `SQLException`

### isCloseOnCompletion

public final boolean isCloseOnCompletion() throws SQLException

Specified by:
  `isCloseOnCompletion` in interface `Statement`
Throws:
  `SQLException`

### closeOnCompletion

public final void closeOnCompletion() throws SQLException

Specified by:
  `closeOnCompletion` in interface `Statement`
Throws:
  `SQLException`

### performCloseOnCompletion

protected final void performCloseOnCompletion() throws SQLException
Closes this statement if `closeOnCompletion` is set to `true`, does nothing if set to `false`.

Throws:
  `SQLException` - for errors closing this statement
See Also:
  - `closeOnCompletion()`
  - `close()`

### fetchConfig

protected final FetchConfig fetchConfig()

Returns:
  current fetch config for this statement
Since:
  6

### resultSetBehavior

protected final ResultSetBehavior resultSetBehavior()

Returns:
  result set behavior for this statement
Since:
  6

### getResultSetType

public final int getResultSetType() throws SQLException

Specified by:
  `getResultSetType` in interface `Statement`
Throws:
  `SQLException`

### getResultSetConcurrency

public final int getResultSetConcurrency() throws SQLException

Specified by:
  `getResultSetConcurrency` in interface `Statement`
Throws:
  `SQLException`

### getResultSetHoldability

public final int getResultSetHoldability() throws SQLException

Specified by:
  `getResultSetHoldability` in interface `Statement`
Throws:
  `SQLException`

### getMaxRows

public final int getMaxRows() throws SQLException

Specified by:
  `getMaxRows` in interface `Statement`
Throws:
  `SQLException`

### setMaxRows

public final void setMaxRows(int max) throws SQLException

Specified by:
  `setMaxRows` in interface `Statement`
Throws:
  `SQLException`

### setLargeMaxRows

public final void setLargeMaxRows(long max) throws SQLException

Jaybird does not support maxRows exceeding `Integer.MAX_VALUE`, if a larger value is set, Jaybird will add a warning to the statement and reset the maximum to 0.

Specified by:
  `setLargeMaxRows` in interface `Statement`
Throws:
  `SQLException`

### getLargeMaxRows

public final long getLargeMaxRows() throws SQLException

Jaybird does not support maxRows exceeding `Integer.MAX_VALUE`, the return value of this method is the same as `getMaxRows()`.

Specified by:
  `getLargeMaxRows` in interface `Statement`
Throws:
  `SQLException`

### getFetchSize

public final int getFetchSize() throws SQLException

Specified by:
  `getFetchSize` in interface `Statement`
Throws:
  `SQLException`

### setFetchSize

public final void setFetchSize(int rows) throws SQLException

Specified by:
  `setFetchSize` in interface `Statement`
Throws:
  `SQLException`

### getFetchDirection

public final int getFetchDirection() throws SQLException

Specified by:
  `getFetchDirection` in interface `Statement`
Throws:
  `SQLException`

### setFetchDirection

public final void setFetchDirection(int direction) throws SQLException

Specified by:
  `setFetchDirection` in interface `Statement`
Throws:
  `SQLException`

### setCursorName

public final void setCursorName(@Nullable String cursorName) throws SQLException

Specified by:
  `setCursorName` in interface `Statement`
Throws:
  `SQLException`

### getCursorName

protected final @Nullable String getCursorName()

Returns:
  current value of `cursorName`
See Also:
  - `setCursorName(String)`

### getWarnings

public final @Nullable SQLWarning getWarnings() throws SQLException

If connection property `reportSQLWarnings` is set to `NONE` (case-insensitive), this method will not report warnings and always return `null`.

Specified by:
  `getWarnings` in interface `Statement`
Throws:
  `SQLException`

### clearWarnings

public final void clearWarnings() throws SQLException

Specified by:
  `clearWarnings` in interface `Statement`
Throws:
  `SQLException`

### addWarning

protected final void addWarning(SQLWarning warning)

### getLocalStatementId

public final int getLocalStatementId()
Description copied from interface: `FirebirdStatement`
The local statement id is intended to identify the statement for internal implementation purposes.

NOTE: This method is only included in this interface to try and avoid problems with proxied and bytecode enhanced classes in certain libraries, you should normally have no reason to call this method directly.

The id is expected - but not guaranteed - to be unique for a single connection, and - preferably - for the entire JVM run time as well.

Specified by:
  `getLocalStatementId` in interface `FirebirdStatement`
Returns:
  The local statement id.

### hashCode

public final int hashCode()

Overrides:
  `hashCode` in class `Object`

### equals

public final boolean equals(Object other)

Overrides:
  `equals` in class `Object`

### withLock

protected final LockCloseable withLock()

See Also:
  - `FbAttachment.withLock()`