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
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
ConstructorsConstructorDescriptionV10Statement(FbWireDatabase database) Creates a new instance of V10Statement for the specified database. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoFreePacket(int option) Handles sending the free statement packet and associated state changes on this statementvoidExecute the statement.voidfetchRows(int fetchSize) Requests this statement to fetch the nextfetchSizerows.protected voidfree(int option) Frees the currently allocated statement.intintvoidPrepare the statement text.protected voidprocessAllocateResponse(GenericResponse response) Processes the allocate response from the server.protected voidprocessExecuteResponse(GenericResponse genericResponse) Process the execute response.protected voidprocessExecuteSingletonResponse(SqlResponse sqlResponse) Process the execute response for statements with a singleton response (op_execute2; stored procedures).protected voidprocessFetchResponse(FetchDirection direction) Process the fetch response by reading the returned rows and queuing them.protected voidprocessFetchResponse(FetchDirection direction, Response response) Process the fetch response by reading the returned rows and queuing them.protected voidprocessFreeResponse(Response response) Processes the response to the free statement.protected voidprocessPrepareResponse(GenericResponse genericResponse) Processes the prepare response from the server.protected byte[]readColumnData(XdrInputStream xdrIn, int len) protected RowValueReads a single row from the database.protected voidSends the allocate request to the server.protected voidsendExecute(int operation, RowValue parameters) Sends the execute (forop_executeorop_execute2) to the database.protected voidsendFetch(int fetchSize) Sends the fetch request to the database.protected voidsendFree(int option) Sends the free statement to the databaseprotected voidsendPrepare(String statementText) Sends the statement prepare to the connection.protected voidsetCursorNameImpl(String cursorName) Implementation ofAbstractFbStatement.setCursorName(String).protected voidwriteColumnData(XdrOutputStream xdrOut, int len, byte[] buffer, FieldDescriptor fieldDescriptor) protected voidwriteSqlData(RowDescriptor rowDescriptor, RowValue fieldValues, boolean useActualLength) Write a set of SQL data from aRowValue.Methods inherited from class org.firebirdsql.gds.ng.wire.AbstractFbWireStatement
calculateBlr, calculateBlr, close, emptyRowDescriptor, getBlrCalculator, getDatabase, getHandle, getInfo, getSqlInfo, getXdrIn, getXdrOut, isValidTransactionClass, setHandle, withLock, wrapDeferredResponseMethods 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, getTransaction, 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, validateParametersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.firebirdsql.gds.ng.listeners.ExceptionListenable
addExceptionListener, removeExceptionListenerMethods 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
Creates a new instance of V10Statement for the specified database.- Parameters:
database- FbWireDatabase implementation
-
-
Method Details
-
free
Description copied from class:AbstractFbStatementFrees the currently allocated statement. Either close the cursor withISCConstants.DSQL_closeor drop the statement handle usingISCConstants.DSQL_drop.- Specified by:
freein classAbstractFbStatement- Parameters:
option- Free option- Throws:
SQLException
-
doFreePacket
Handles sending the free statement packet and associated state changes on this statement- Parameters:
option- free statement option- Throws:
SQLExceptionIOException
-
sendFree
Sends the free statement to the database- Parameters:
option- Free statement option- Throws:
IOExceptionSQLException
-
processFreeResponse
Processes the response to the free statement.- Parameters:
response- Response object
-
prepare
Description copied from interface:FbStatementPrepare the statement text.If this handle is in state
StatementState.NEWthen it will first allocate the statement.- Specified by:
preparein interfaceFbStatement- Parameters:
statementText- Statement text- Throws:
SQLException- If a database access error occurs, or this statement is currently executing a query.
-
sendPrepare
Sends the statement prepare to the connection.- Parameters:
statementText- Statement- Throws:
SQLExceptionIOException
-
processPrepareResponse
Processes the prepare response from the server.- Parameters:
genericResponse- GenericResponse- Throws:
SQLException
-
setCursorNameImpl
Description copied from class:AbstractFbStatementImplementation ofAbstractFbStatement.setCursorName(String).The caller of this method will take out the lock, check statement validity and call
exceptionListenerDispatcherfor exceptions, so implementations of this method do not need to do so.- Specified by:
setCursorNameImplin classAbstractFbStatement- Parameters:
cursorName- Name of the cursor- Throws:
SQLException- If this statement is closed, or if the cursor name is set andcursorNameis different from the current cursor name
-
execute
Description copied from interface:FbStatementExecute the statement.- Specified by:
executein interfaceFbStatement- 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 byFbStatement.getParameterDescriptor(), a parameter value was not set, or when an error occurred executing this statement.
-
sendExecute
Sends the execute (forop_executeorop_execute2) to the database.- Parameters:
operation- Operation (op_executeorop_execute2)parameters- Parameters- Throws:
IOExceptionSQLException
-
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:
SQLExceptionIOException
-
processExecuteResponse
Process the execute response.- Parameters:
genericResponse- Generic response object
-
fetchRows
Description copied from interface:FbStatementRequests this statement to fetch the nextfetchSizerows.Fetched rows are not returned from this method, but sent to the registered
StatementListenerinstances.If an asynchronous fetch is pending, that pending fetch should be completed instead of performing a new fetch.
- Specified by:
fetchRowsin interfaceFbStatement- Parameters:
fetchSize- Number of rows to fetch (must be greater than0)- 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 than0- See Also:
-
processFetchResponse
Process the fetch response by reading the returned rows and queuing them.- Parameters:
direction- fetch direction- Throws:
IOExceptionSQLException
-
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 directionresponse- initial response, ornullto retrieve initial response- Throws:
IOExceptionSQLException
-
sendFetch
Sends the fetch request to the database.- Parameters:
fetchSize- Number of rows to fetch.- Throws:
SQLExceptionIOException
-
readSqlData
Reads a single row from the database.- Returns:
- Row as a
RowValue - Throws:
SQLExceptionIOException
-
readColumnData
- Throws:
IOException
-
writeSqlData
protected void writeSqlData(RowDescriptor rowDescriptor, RowValue fieldValues, boolean useActualLength) throws IOException, SQLException Write a set of SQL data from aRowValue.- Parameters:
rowDescriptor- The row descriptorfieldValues- The List containing the SQL data to be writtenuseActualLength- Should actual field length be used (applies to CHAR)- Throws:
IOException- if an error occurs while writing to the underlying output streamSQLException
-
writeColumnData
protected void writeColumnData(XdrOutputStream xdrOut, int len, byte[] buffer, FieldDescriptor fieldDescriptor) throws IOException - Throws:
IOException
-
sendAllocate
Sends the allocate request to the server.- Throws:
SQLExceptionIOException
-
processAllocateResponse
Processes the allocate response from the server.- Parameters:
response- GenericResponse- Throws:
SQLException
-
getDefaultSqlInfoSize
public int getDefaultSqlInfoSize()- Specified by:
getDefaultSqlInfoSizein interfaceFbStatement- Returns:
- The default size to use for the sql info buffer
-
getMaxSqlInfoSize
public int getMaxSqlInfoSize()- Specified by:
getMaxSqlInfoSizein interfaceFbStatement- Returns:
- The maximum size to use for the sql info buffer
-