Module org.firebirdsql.jaybird
Package org.firebirdsql.gds.ng.wire.version10

# Class V10Statement

java.lang.Object
org.firebirdsql.gds.ng.AbstractFbStatement
org.firebirdsql.gds.ng.wire.AbstractFbWireStatement
org.firebirdsql.gds.ng.wire.version10.V10Statement

All Implemented Interfaces:
  `AutoCloseable`, `FbStatement`, `ExceptionListenable`, `FbWireStatement`

Direct Known Subclasses:
  `V11Statement`

public class V10Statement extends AbstractFbWireStatement implements FbWireStatement
`FbWireStatement` implementation for the version 10 wire protocol.

Since:
  3.0
Author:
  Mark Rotteveel

## Field Summary

### Fields inherited from class org.firebirdsql.gds.ng.AbstractFbStatement

`exceptionListenerDispatcher, statementListenerDispatcher`

## Constructor Summary

Constructors
Constructor
Description
`V10Statement(FbWireDatabase database)`
Creates a new instance of V10Statement for the specified database.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`doFreePacket(int option)`
Handles sending the free statement packet and associated state changes on this statement
`void`
`execute(RowValue parameters)`
Execute the statement.
`void`
`fetchRows(int fetchSize)`
Requests this statement to fetch the next `fetchSize` rows.
`protected void`
`free(int option)`
Frees the currently allocated statement.
`int`
`getDefaultSqlInfoSize()`
`int`
`getMaxSqlInfoSize()`
`void`
`prepare(String statementText)`
Prepare the statement text.
`protected void`
`processAllocateResponse(GenericResponse response)`
Processes the allocate response from the server.
`protected void`
`processExecuteResponse(GenericResponse genericResponse)`
Process the execute response.
`protected void`
`processExecuteSingletonResponse(SqlResponse sqlResponse)`
Process the execute response for statements with a singleton response (`op_execute2`; stored procedures).
`protected void`
`processFetchResponse(FetchDirection direction)`
Process the fetch response by reading the returned rows and queuing them.
`protected void`
`processFetchResponse(FetchDirection direction, Response response)`
Process the fetch response by reading the returned rows and queuing them.
`protected void`
`processFreeResponse(Response response)`
Processes the response to the free statement.
`protected void`
`processPrepareResponse(GenericResponse genericResponse)`
Processes the prepare response from the server.
`protected byte[]`
`readColumnData(XdrInputStream xdrIn, int len)`
`protected RowValue`
`readSqlData()`
Reads a single row from the database.
`protected void`
`sendAllocate()`
Sends the allocate request to the server.
`protected void`
`sendExecute(int operation, RowValue parameters)`
Sends the execute (for `op_execute` or `op_execute2`) to the database.
`protected void`
`sendExecuteMsg(XdrOutputStream xdrOut, int operation, RowValue parameters)`
Sends the execute message (struct `p_sqldata`) to the server, without flushing.
`protected void`
`sendFetch(int fetchSize)`
Sends the fetch request to the database.
`protected void`
`sendFree(int option)`
Sends the free statement to the database
`protected void`
`sendPrepare(String statementText)`
Sends the statement prepare to the connection.
`protected void`
`setCursorNameImpl(String cursorName)`
Implementation of `AbstractFbStatement.setCursorName(String)`.
`protected void`
`writeColumnData(XdrOutputStream xdrOut, int len, byte[] buffer, FieldDescriptor fieldDescriptor)`
Writes a column.
`protected void`
`writeSqlData(RowDescriptor rowDescriptor, RowValue fieldValues, boolean useActualLength)`
Write a set of SQL data from a `RowValue`.

### Methods inherited from class org.firebirdsql.gds.ng.wire.AbstractFbWireStatement

`calculateBlr, calculateBlr, close, emptyRowDescriptor, getBlrCalculator, getDatabase, getHandle, getInfo, getSqlInfo, getTransaction, getXdrIn, getXdrOut, handleInlineBlobResponse, isValidTransactionClass, setHandle, withLock, withTransmitLock, wrapDeferredResponse`

### Methods inherited from class org.firebirdsql.gds.ng.AbstractFbStatement

`addExceptionListener, addStatementListener, addWeakStatementListener, asyncFetchRows, checkFetchSize, checkPrepareAllowed, checkStatementHasOpenCursor, checkStatementValid, checkStatementValid, closeCursor, closeCursor, createExecutionPlanProcessor, createSqlCountProcessor, ensureClosedCursor, fetchScroll, fetchScrollImpl, forceState, getAllowedTimeout, getCursorInfo, getCursorInfo, getCursorInfoImpl, getCursorName, getExecutionPlan, getExplainedExecutionPlan, getParameterDescriptionInfoRequestItems, getParameterDescriptor, getRowDescriptor, getSqlCounts, getSqlInfo, getState, getStatementInfoRequestItems, getStatementWarningCallback, getTimeout, getTransactionListener, getType, hasFetched, hasFields, hasSingletonResult, isAfterLast, isBeforeFirst, isPrepareAllowed, parseStatementInfo, queueRowData, removeExceptionListener, removeStatementListener, reset, reset, resetAll, setAfterLast, setBeforeFirst, setCursorName, setParameterDescriptor, setRowDescriptor, setTimeout, setTransaction, setType, signalAsyncFetchComplete, signalAsyncFetchStart, signalExecute, signalFetch, switchState, unprepare, validateParameters`

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

`clone, equals, finalize, 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.FbStatement

`addStatementListener, addWeakStatementListener, asyncFetchRows, batchCancel, batchExecute, clearCursorFlag, close, closeCursor, closeCursor, createBatchParameterBuffer, deferredBatchCreate, deferredBatchRelease, deferredBatchSend, emptyRowDescriptor, ensureClosedCursor, fetchScroll, getCursorInfo, getCursorInfo, getDatabase, getExecutionPlan, getExplainedExecutionPlan, getHandle, getParameterDescriptor, getRowDescriptor, getSqlCounts, getSqlInfo, getSqlInfo, getState, getTimeout, getTransaction, getType, hasFetched, isCursorFlagSet, removeStatementListener, setCursorFlag, setCursorName, setTimeout, setTransaction, supportBatchUpdates, supportsCursorInfo, supportsFetchScroll, unprepare, validateParameters, withLock`

## Constructor Details

### V10Statement

public V10Statement(FbWireDatabase database)
Creates a new instance of V10Statement for the specified database.

Parameters:
  `database` - FbWireDatabase implementation

## Method Details

### free

protected void free(int option) throws SQLException
Description copied from class: `AbstractFbStatement`
Frees the currently allocated statement. Either close the cursor with `ISCConstants.DSQL_close` or drop the statement handle using `ISCConstants.DSQL_drop`.

Specified by:
  `free` in class `AbstractFbStatement`
Parameters:
  `option` - Free option
Throws:
  `SQLException`

### doFreePacket

protected void doFreePacket(int option) throws SQLException, IOException
Handles sending the free statement packet and associated state changes on this statement

Parameters:
  `option` - free statement option
Throws:
  `SQLException`
  `IOException`

### sendFree

protected void sendFree(int option) throws IOException, SQLException
Sends the free statement to the database

Parameters:
  `option` - Free statement option
Throws:
  `IOException`
  `SQLException`

### processFreeResponse

protected void processFreeResponse(Response response)
Processes the response to the free statement.

Parameters:
  `response` - Response object

### prepare

public void prepare(String statementText) throws SQLException
Description copied from interface: `FbStatement`
Prepare the statement text.

If this handle is in state `StatementState.NEW` then it will first allocate the statement.

Specified by:
  `prepare` in interface `FbStatement`
Parameters:
  `statementText` - Statement text
Throws:
  `SQLException` - If a database access error occurs, or this statement is currently executing a query.

### sendPrepare

protected void sendPrepare(String statementText) throws SQLException, IOException
Sends the statement prepare to the connection.

Parameters:
  `statementText` - Statement
Throws:
  `SQLException`
  `IOException`

### processPrepareResponse

protected void processPrepareResponse(GenericResponse genericResponse) throws SQLException
Processes the prepare response from the server.

Parameters:
  `genericResponse` - GenericResponse
Throws:
  `SQLException`

### setCursorNameImpl

protected void setCursorNameImpl(String cursorName) throws SQLException
Description copied from class: `AbstractFbStatement`
Implementation of `AbstractFbStatement.setCursorName(String)`.

The caller of this method will take out the lock, check statement validity and call `exceptionListenerDispatcher` for exceptions, so implementations of this method do not need to do so.

Specified by:
  `setCursorNameImpl` in class `AbstractFbStatement`
Parameters:
  `cursorName` - Name of the cursor
Throws:
  `SQLException` - If this statement is closed, or if the cursor name is set and `cursorName` is different from the current cursor name

### execute

public void execute(RowValue parameters) throws SQLException
Description copied from interface: `FbStatement`
Execute the statement.

Specified by:
  `execute` in interface `FbStatement`
Parameters:
  `parameters` - The list of parameter values to use for execution.
Throws:
  `SQLException` - When the number of type of parameters does not match the types returned by `FbStatement.getParameterDescriptor()`, a parameter value was not set, or when an error occurred executing this statement.

### sendExecute

protected void sendExecute(int operation, RowValue parameters) throws IOException, SQLException
Sends the execute (for `op_execute` or `op_execute2`) to the database.

Parameters:
  `operation` - Operation (`op_execute` or `op_execute2`)
  `parameters` - Parameters
Throws:
  `IOException`
  `SQLException`

### sendExecuteMsg

protected void sendExecuteMsg(XdrOutputStream xdrOut, int operation, RowValue parameters) throws IOException, SQLException
Sends the execute message (struct `p_sqldata`) to the server, without flushing.

The caller is responsible for obtaining and releasing the transmit lock.

Parameters:
  `xdrOut` - XDR output stream
  `operation` - operation (`op_execute` or `op_execute2`)
  `parameters` - parameter values
Throws:
  `IOException`
  `SQLException`

### processExecuteSingletonResponse

protected void processExecuteSingletonResponse(SqlResponse sqlResponse) throws SQLException, IOException
Process the execute response for statements with a singleton response (`op_execute2`; stored procedures).

Parameters:
  `sqlResponse` - SQL response object
Throws:
  `SQLException`
  `IOException`

### processExecuteResponse

protected void processExecuteResponse(GenericResponse genericResponse)
Process the execute response.

Parameters:
  `genericResponse` - Generic response object

### fetchRows

public void fetchRows(int fetchSize) throws SQLException
Description copied from interface: `FbStatement`
Requests this statement to fetch the next `fetchSize` rows.

Fetched rows are not returned from this method, but sent to the registered `StatementListener` instances.

If an asynchronous fetch is pending, that pending fetch should be completed instead of performing a new fetch.

Specified by:
  `fetchRows` in interface `FbStatement`
Parameters:
  `fetchSize` - Number of rows to fetch (must be greater than `0`)
Throws:
  `SQLException` - For database access errors, when called on a closed statement, when no cursor is open or when the fetch size is not greater than `0`
See Also:
  - `FbStatement.asyncFetchRows(int)`

### processFetchResponse

protected void processFetchResponse(FetchDirection direction) throws IOException, SQLException
Process the fetch response by reading the returned rows and queuing them.

Parameters:
  `direction` - fetch direction
Throws:
  `IOException`
  `SQLException`

### processFetchResponse

protected void processFetchResponse(FetchDirection direction, Response response) throws IOException, SQLException
Process the fetch response by reading the returned rows and queuing them.

Parameters:
  `direction` - fetch direction
  `response` - initial response, or `null` to retrieve initial response
Throws:
  `IOException`
  `SQLException`

### sendFetch

protected void sendFetch(int fetchSize) throws SQLException, IOException
Sends the fetch request to the database.

Parameters:
  `fetchSize` - Number of rows to fetch.
Throws:
  `SQLException`
  `IOException`

### readSqlData

protected RowValue readSqlData() throws SQLException, IOException
Reads a single row from the database.

Returns:
  Row as a `RowValue`
Throws:
  `SQLException`
  `IOException`

### readColumnData

protected byte[] readColumnData(XdrInputStream xdrIn, int len) throws IOException

Throws:
  `IOException`

### writeSqlData

protected void writeSqlData(RowDescriptor rowDescriptor, RowValue fieldValues, boolean useActualLength) throws IOException, SQLException
Write a set of SQL data from a `RowValue`.

Parameters:
  `rowDescriptor` - The row descriptor
  `fieldValues` - The List containing the SQL data to be written
  `useActualLength` - Should actual field length be used (applies to CHAR)
Throws:
  `IOException` - if an error occurs while writing to the underlying output stream
  `SQLException`

### writeColumnData

protected void writeColumnData(XdrOutputStream xdrOut, int len, byte[] buffer, FieldDescriptor fieldDescriptor) throws IOException
Writes a column.

The caller is responsible for obtaining and releasing the transmit lock.

Throws:
  `IOException`

### sendAllocate

protected void sendAllocate() throws SQLException, IOException
Sends the allocate request to the server.

Throws:
  `SQLException`
  `IOException`

### processAllocateResponse

protected void processAllocateResponse(GenericResponse response) throws SQLException
Processes the allocate response from the server.

Parameters:
  `response` - GenericResponse
Throws:
  `SQLException`

### getDefaultSqlInfoSize

public int getDefaultSqlInfoSize()

Specified by:
  `getDefaultSqlInfoSize` in interface `FbStatement`
Returns:
  The default size to use for the sql info buffer

### getMaxSqlInfoSize

public int getMaxSqlInfoSize()

Specified by:
  `getMaxSqlInfoSize` in interface `FbStatement`
Returns:
  The maximum size to use for the sql info buffer