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:
- java.lang.AutoCloseable,- FbStatement,- ExceptionListenable
 
 public class JnaStatement extends AbstractFbStatement Implementation ofFbStatementfor native client access.- Since:
- 3.0
- Author:
- Mark Rotteveel
 
- 
- 
Field Summary- 
Fields inherited from class org.firebirdsql.gds.ng.AbstractFbStatementexceptionListenerDispatcher, statementListenerDispatcher
 
- 
 - 
Constructor SummaryConstructors Constructor Description JnaStatement(JnaDatabase database)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected XSQLDAallocateXSqlDa(RowDescriptor rowDescriptor)Creates an XSQLDA, populates type information and allocates memory for the sqldata fields.RowDescriptoremptyRowDescriptor()voidexecute(RowValue parameters)Execute the statement.voidfetchRows(int fetchSize)Requests this statement to fetch the nextfetchSizerows.protected voidfree(int option)Frees the currently allocated statement.JnaDatabasegetDatabase()intgetDefaultSqlInfoSize()intgetHandle()intgetMaxSqlInfoSize()byte[]getSqlInfo(byte[] requestItems, int bufferLength)Request statement info.JnaTransactiongetTransaction()protected booleanisValidTransactionClass(java.lang.Class<? extends FbTransaction> transactionClass)Method to decide if a transaction implementation class is valid for the statement implementation.voidprepare(java.lang.String statementText)Prepare the statement text.voidsetCursorName(java.lang.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.LockCloseablewithLock()Locks the lock withLock.lock()(or equivalent).- 
Methods inherited from class org.firebirdsql.gds.ng.AbstractFbStatementaddExceptionListener, addStatementListener, checkStatementValid, checkStatementValid, close, closeCursor, closeCursor, createExecutionPlanProcessor, createSqlCountProcessor, ensureClosedCursor, fetchScroll, fetchScrollImpl, finalize, forceState, getAllowedTimeout, getCursorInfo, getCursorInfo, getCursorInfoImpl, 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, setTimeout, setTransaction, setType, signalExecute, signalFetch, switchState, unprepare, validateParameters
 - 
Methods inherited from class java.lang.Objectclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.firebirdsql.gds.ng.FbStatementbatchCancel, batchExecute, clearCursorFlag, createBatchParameterBuffer, deferredBatchCreate, deferredBatchRelease, deferredBatchSend, isCursorFlagSet, setCursorFlag, supportBatchUpdates, supportsCursorInfo, supportsFetchScroll
 
- 
 
- 
- 
- 
Constructor Detail- 
JnaStatementpublic JnaStatement(JnaDatabase database) 
 
- 
 - 
Method Detail- 
withLockpublic final LockCloseable withLock() Description copied from interface:FbStatementLocks the lock withLock.lock()(or equivalent).Implementations are expected to apply the same lock as FbAttachment.withLock().- Returns:
- lock closeable which unlocks the lock on close
- See Also:
- FbAttachment.withLock()
 
 - 
setParameterDescriptorprotected void setParameterDescriptor(RowDescriptor parameterDescriptor) Description copied from class:AbstractFbStatementSets the parameter descriptor.- Overrides:
- setParameterDescriptorin class- AbstractFbStatement
- Parameters:
- parameterDescriptor- Parameter descriptor
 
 - 
setRowDescriptorprotected void setRowDescriptor(RowDescriptor fieldDescriptor) Description copied from class:AbstractFbStatementSets the (result set) row descriptor.- Overrides:
- setRowDescriptorin class- AbstractFbStatement
- Parameters:
- fieldDescriptor- Row descriptor
 
 - 
freeprotected void free(int option) throws java.sql.SQLExceptionDescription 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 class- AbstractFbStatement
- Parameters:
- option- Free option
- Throws:
- java.sql.SQLException
 
 - 
isValidTransactionClassprotected boolean isValidTransactionClass(java.lang.Class<? extends FbTransaction> transactionClass) 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 class- AbstractFbStatement
- Parameters:
- transactionClass- Class of the transaction
- Returns:
- truewhen the transaction class is valid for the statement implementation.
 
 - 
getDatabasepublic JnaDatabase getDatabase() - Returns:
- The database connection that created this statement
 
 - 
getHandlepublic int getHandle() - Returns:
- The Firebird statement handle identifier
 
 - 
getTransactionpublic JnaTransaction getTransaction() - Specified by:
- getTransactionin interface- FbStatement
- Overrides:
- getTransactionin class- AbstractFbStatement
- Returns:
- Transaction currently associated with this statement
 
 - 
preparepublic void prepare(java.lang.String statementText) throws java.sql.SQLExceptionDescription 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:
- java.sql.SQLException- If a database access error occurs, or this statement is currently executing a query.
 
 - 
executepublic void execute(RowValue parameters) throws java.sql.SQLException Description copied from interface:FbStatementExecute the statement.- Parameters:
- parameters- The list of parameter values to use for execution.
- Throws:
- java.sql.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.
 
 - 
setXSqlDaDataprotected void setXSqlDaData(XSQLDA xSqlDa, RowDescriptor rowDescriptor, RowValue parameters) Populates an XSQLDA from the row descriptor and parameter values.- Parameters:
- xSqlDa- XSQLDA
- rowDescriptor- Row descriptor
- parameters- Parameter values
 
 - 
allocateXSqlDaprotected XSQLDA allocateXSqlDa(RowDescriptor rowDescriptor) Creates an XSQLDA, populates type information and allocates memory for the sqldata fields.- Parameters:
- rowDescriptor- The row descriptor
- Returns:
- Allocated XSQLDA without data
 
 - 
toRowValueprotected RowValue toRowValue(RowDescriptor rowDescriptor, XSQLDA xSqlDa) Converts the data from an XSQLDA to a RowValue.- Parameters:
- rowDescriptor- Row descriptor
- xSqlDa- XSQLDA
- Returns:
- Row value
 
 - 
fetchRowspublic void fetchRows(int fetchSize) throws java.sql.SQLExceptionRequests 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 greater than- 0)
- Throws:
- java.sql.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.
 
 - 
getSqlInfopublic byte[] getSqlInfo(byte[] requestItems, int bufferLength) throws java.sql.SQLExceptionDescription copied from interface:FbStatementRequest statement info.- Parameters:
- requestItems- Array of info items to request
- bufferLength- Response buffer length to use
- Returns:
- Response buffer
- Throws:
- java.sql.SQLException- For errors retrieving or transforming the response.
 
 - 
getDefaultSqlInfoSizepublic int getDefaultSqlInfoSize() - Returns:
- The default size to use for the sql info buffer
 
 - 
getMaxSqlInfoSizepublic int getMaxSqlInfoSize() - Returns:
- The maximum size to use for the sql info buffer
 
 - 
setCursorNamepublic void setCursorName(java.lang.String cursorName) throws java.sql.SQLExceptionDescription copied from interface:FbStatementSets the named cursor name for this statement.- Parameters:
- cursorName- Name of the cursor
- Throws:
- java.sql.SQLException- If this statement is closed, TODO: Other reasons (eg cursor open)?
 
 - 
emptyRowDescriptorpublic final RowDescriptor emptyRowDescriptor() - Returns:
- A potentially cached empty row descriptor for this statement or database.
 
 
- 
 
-