public class JnaStatement extends AbstractFbStatement
FbStatement
for native client access.exceptionListenerDispatcher, statementListenerDispatcher
Constructor and Description |
---|
JnaStatement(JnaDatabase database) |
Modifier and Type | Method and Description |
---|---|
protected XSQLDA |
allocateXSqlDa(RowDescriptor rowDescriptor)
Creates an XSQLDA, populates type information and allocates memory for the sqldata fields.
|
RowDescriptor |
emptyRowDescriptor() |
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 (either close the cursor with
ISCConstants.DSQL_close or drop the statement
handle using ISCConstants.DSQL_drop . |
JnaDatabase |
getDatabase() |
int |
getDefaultSqlInfoSize() |
int |
getHandle() |
int |
getMaxSqlInfoSize() |
byte[] |
getSqlInfo(byte[] requestItems,
int bufferLength)
Request statement info.
|
JnaTransaction |
getTransaction() |
protected boolean |
isValidTransactionClass(java.lang.Class<? extends FbTransaction> transactionClass)
Method to decide if a transaction implementation class is valid for the statement implementation.
|
void |
prepare(java.lang.String statementText)
Prepare the statement text.
|
void |
setCursorName(java.lang.String cursorName)
Sets the named cursor name for this statement.
|
protected void |
setFieldDescriptor(RowDescriptor fieldDescriptor)
Sets the (result set) field descriptor.
|
protected void |
setParameterDescriptor(RowDescriptor parameterDescriptor)
Sets the parameter descriptor.
|
protected void |
setXSqlDaData(XSQLDA xSqlDa,
RowDescriptor rowDescriptor,
RowValue parameters)
Populates an XSQLDA from the row descriptor and parameter values.
|
protected RowValue |
toRowValue(RowDescriptor rowDescriptor,
XSQLDA xSqlDa)
Converts the data from an XSQLDA to a RowValue.
|
addExceptionListener, addStatementListener, checkStatementValid, close, closeCursor, closeCursor, createExecutionPlanProcessor, createSqlCountProcessor, ensureClosedCursor, finalize, getExecutionPlan, getFieldDescriptor, getParameterDescriptionInfoRequestItems, getParameterDescriptor, getSqlCounts, getSqlInfo, getState, getStatementInfoRequestItems, getStatementWarningCallback, getSynchronizationObject, getTransactionListener, getType, hasFields, hasSingletonResult, isAllRowsFetched, isPrepareAllowed, parseStatementInfo, queueRowData, removeExceptionListener, removeStatementListener, reset, reset, resetAll, setAllRowsFetched, setTransaction, setType, switchState, validateParameters
public JnaStatement(JnaDatabase database)
protected void setParameterDescriptor(RowDescriptor parameterDescriptor)
AbstractFbStatement
setParameterDescriptor
in class AbstractFbStatement
parameterDescriptor
- Parameter descriptorprotected void setFieldDescriptor(RowDescriptor fieldDescriptor)
AbstractFbStatement
setFieldDescriptor
in class AbstractFbStatement
fieldDescriptor
- Field descriptorprotected void free(int option) throws java.sql.SQLException
AbstractFbStatement
ISCConstants.DSQL_close
or drop the statement
handle using ISCConstants.DSQL_drop
.free
in class AbstractFbStatement
option
- Free optionjava.sql.SQLException
protected boolean isValidTransactionClass(java.lang.Class<? extends FbTransaction> transactionClass)
AbstractFbStatement
Eg a V10Statement
will only work with an
FbWireTransaction
implementation.
isValidTransactionClass
in class AbstractFbStatement
transactionClass
- Class of the transactiontrue
when the transaction class is valid for the statement implementation.public JnaDatabase getDatabase()
public int getHandle()
public JnaTransaction getTransaction()
getTransaction
in interface FbStatement
getTransaction
in class AbstractFbStatement
public void prepare(java.lang.String statementText) throws java.sql.SQLException
FbStatement
If this handle is in state StatementState.NEW
then it will first allocate the statement.
statementText
- Statement textjava.sql.SQLException
- If a database access error occurs, or this statement is currently executing a query.public void execute(RowValue parameters) throws java.sql.SQLException
FbStatement
parameters
- The list of parameter values to use for execution.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.protected void setXSqlDaData(XSQLDA xSqlDa, RowDescriptor rowDescriptor, RowValue parameters)
xSqlDa
- XSQLDArowDescriptor
- Row descriptorparameters
- Parameter valuesprotected XSQLDA allocateXSqlDa(RowDescriptor rowDescriptor)
rowDescriptor
- The row descriptorprotected RowValue toRowValue(RowDescriptor rowDescriptor, XSQLDA xSqlDa)
rowDescriptor
- Row descriptorxSqlDa
- XSQLDApublic void fetchRows(int fetchSize) throws java.sql.SQLException
fetchSize
rows.
Fetched rows are not returned from this method, but sent to the registered StatementListener
instances.
The JNA implementation ignores the specified fetchSize
to 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.
fetchSize
- Number of rows to fetch (must be > 0
)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 > 0
.public byte[] getSqlInfo(byte[] requestItems, int bufferLength) throws java.sql.SQLException
FbStatement
requestItems
- Array of info items to requestbufferLength
- Response buffer length to usejava.sql.SQLException
public int getDefaultSqlInfoSize()
public int getMaxSqlInfoSize()
public void setCursorName(java.lang.String cursorName) throws java.sql.SQLException
FbStatement
cursorName
- Name of the cursorjava.sql.SQLException
- If this statement is closed, TODO: Other reasons (eg cursor open)?public final RowDescriptor emptyRowDescriptor()
Copyright © 2001-2021 Jaybird (Firebird JDBC/JCA) team. All rights reserved.