Package org.firebirdsql.gds.ng.jna
Class JnaStatement
java.lang.Object
org.firebirdsql.gds.ng.AbstractFbStatement
org.firebirdsql.gds.ng.jna.JnaStatement
- All Implemented Interfaces:
FbStatement,ExceptionListenable
Implementation of
FbStatement for native client access.- Since:
- 3.0
- Author:
- Mark Rotteveel
-
Field Summary
Fields inherited from class org.firebirdsql.gds.ng.AbstractFbStatement
exceptionListenerDispatcher, statementListenerDispatcher -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected XSQLDAallocateXSqlDa(RowDescriptor rowDescriptor) Creates an XSQLDA, populates type information and allocates memory for the sqldata fields.final RowDescriptorvoidExecute the statement.voidfetchRows(int fetchSize) Requests this statement to fetch the nextfetchSizerows.protected voidfree(int option) Frees the currently allocated statement (either close the cursor withISCConstants.DSQL_closeor drop the statement handle usingISCConstants.DSQL_drop.intintintbyte[]getSqlInfo(byte[] requestItems, int bufferLength) Request statement info.protected booleanisValidTransactionClass(Class<? extends FbTransaction> transactionClass) Method to decide if a transaction implementation class is valid for the statement implementation.voidPrepare the statement text.voidsetCursorName(String cursorName) Sets the named cursor name for this statement.protected voidsetParameterDescriptor(RowDescriptor parameterDescriptor) Sets the parameter descriptor.protected voidsetRowDescriptor(RowDescriptor fieldDescriptor) Sets the (result set) row descriptor.protected voidsetXSqlDaData(XSQLDA xSqlDa, RowDescriptor rowDescriptor, RowValue parameters) Populates an XSQLDA from the row descriptor and parameter values.protected RowValuetoRowValue(RowDescriptor rowDescriptor, XSQLDA xSqlDa) Converts the data from an XSQLDA to a RowValue.Methods inherited from class org.firebirdsql.gds.ng.AbstractFbStatement
addExceptionListener, addStatementListener, checkStatementValid, checkStatementValid, close, closeCursor, closeCursor, createExecutionPlanProcessor, createSqlCountProcessor, ensureClosedCursor, finalize, getAllowedTimeout, getExecutionPlan, getExplainedExecutionPlan, getFieldDescriptor, getParameterDescriptionInfoRequestItems, getParameterDescriptor, getRowDescriptor, getSqlCounts, getSqlInfo, getState, getStatementInfoRequestItems, getStatementWarningCallback, getSynchronizationObject, getTimeout, getTransactionListener, getType, hasFields, hasSingletonResult, isAllRowsFetched, isPrepareAllowed, parseStatementInfo, queueRowData, removeExceptionListener, removeStatementListener, reset, reset, resetAll, setAllRowsFetched, setFieldDescriptor, setTimeout, setTransaction, setType, signalExecute, signalFetch, switchState, validateParameters
-
Constructor Details
-
JnaStatement
-
-
Method Details
-
setParameterDescriptor
Description copied from class:AbstractFbStatementSets the parameter descriptor.- Overrides:
setParameterDescriptorin classAbstractFbStatement- Parameters:
parameterDescriptor- Parameter descriptor
-
setRowDescriptor
Description copied from class:AbstractFbStatementSets the (result set) row descriptor.- Overrides:
setRowDescriptorin classAbstractFbStatement- Parameters:
fieldDescriptor- Row descriptor
-
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
-
isValidTransactionClass
Description copied from class:AbstractFbStatementMethod to decide if a transaction implementation class is valid for the statement implementation.Eg a
V10Statementwill only work with anFbWireTransactionimplementation.- Specified by:
isValidTransactionClassin classAbstractFbStatement- Parameters:
transactionClass- Class of the transaction- Returns:
truewhen the transaction class is valid for the statement implementation.
-
getDatabase
- Returns:
- The database connection that created this statement
-
getHandle
public int getHandle()- Returns:
- The Firebird statement handle identifier
-
getTransaction
- Specified by:
getTransactionin interfaceFbStatement- Overrides:
getTransactionin classAbstractFbStatement- Returns:
- Transaction currently associated with this statement
-
prepare
Description copied from interface:FbStatementPrepare the statement text.If this handle is in state
StatementState.NEWthen it will first allocate the statement.- Parameters:
statementText- Statement text- Throws:
SQLException- If a database access error occurs, or this statement is currently executing a query.
-
execute
Description copied from interface:FbStatementExecute the statement.- 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.
-
setXSqlDaData
Populates an XSQLDA from the row descriptor and parameter values.- Parameters:
xSqlDa- XSQLDArowDescriptor- Row descriptorparameters- Parameter values
-
allocateXSqlDa
Creates an XSQLDA, populates type information and allocates memory for the sqldata fields.- Parameters:
rowDescriptor- The row descriptor- Returns:
- Allocated XSQLDA without data
-
toRowValue
Converts the data from an XSQLDA to a RowValue.- Parameters:
rowDescriptor- Row descriptorxSqlDa- XSQLDA- Returns:
- Row value
-
fetchRows
Requests this statement to fetch the nextfetchSizerows.Fetched rows are not returned from this method, but sent to the registered
StatementListenerinstances.The JNA implementation ignores the specified
fetchSizeto prevent problems with - for example - positioned updates with named cursors. For the wire protocol that case is handled by the server ignoring the fetch size. Internally the native fetch will batch a number of records, but the number is outside our control.- Parameters:
fetchSize- Number of rows to fetch (must be> 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> 0.
-
getSqlInfo
Description copied from interface:FbStatementRequest statement info.- Parameters:
requestItems- Array of info items to requestbufferLength- Response buffer length to use- Returns:
- Response buffer
- Throws:
SQLException
-
getDefaultSqlInfoSize
public int getDefaultSqlInfoSize()- Returns:
- The default size to use for the sql info buffer
-
getMaxSqlInfoSize
public int getMaxSqlInfoSize()- Returns:
- The maximum size to use for the sql info buffer
-
setCursorName
Description copied from interface:FbStatementSets the named cursor name for this statement.- Parameters:
cursorName- Name of the cursor- Throws:
SQLException- If this statement is closed, TODO: Other reasons (eg cursor open)?
-
emptyRowDescriptor
- Returns:
- A potentially cached empty row descriptor for this statement or database.
-