public interface Statement
extends java.lang.AutoCloseable
To create a statement object, call
Session.createStatement
.
A program that creates a statement object must explicitly call
Statement.close
to reclaim its resources.
This interface is implemented internally. Applications do not implement this interface.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
TIBDG_STATEMENT_CONSISTENCY_GLOBAL_SNAPSHOT
Global snapshot consistency; property value constant.
|
static java.lang.String |
TIBDG_STATEMENT_CONSISTENCY_SNAPSHOT
Snapshot consistency; property value constant.
|
static java.lang.String |
TIBDG_STATEMENT_PROPERTY_DOUBLE_FETCH_TIMEOUT
Property name for the Statement fetch timeout; double.
|
static java.lang.String |
TIBDG_STATEMENT_PROPERTY_LONG_PREFETCH
Property name for Statement query prefetch; long.
|
static java.lang.String |
TIBDG_STATEMENT_PROPERTY_STRING_CONSISTENCY
Property name for Statement consistency; string.
|
Modifier and Type | Method and Description |
---|---|
void |
clearParameters()
Clears all of the parameter values set on the statement object.
|
void |
close()
Close the statement object.
|
ResultSet |
executeQuery(java.util.Properties props)
Executes the query on the statement object and returns the resultset object.
|
long |
executeUpdate(java.util.Properties props)
Executes the SQL statement in this
Statement object, which must be an SQL
Data Manipulation Language (DML) statement, such as INSERT . |
long |
getParameterCount()
Returns the number of parameters in the statement.
|
ResultSetMetadata |
getResultSetMetadata()
Get the metadata associated with a statement
|
void |
setDateTime(int parameterIndex,
TibDateTime value)
Sets a TibDateTime value to a parameter number in a statement object.
|
void |
setDouble(int parameterIndex,
double value)
Sets a double value to a parameter number in a statement object.
|
void |
setLong(int parameterIndex,
long value)
Sets a long value to a parameter number in a statement object.
|
void |
setNull(int parameterIndex)
Sets an empty value for a parameter number in a statement object.
|
void |
setOpaque(int parameterIndex,
byte[] value)
Sets an opaque value to a parameter number in a statement object.
|
void |
setString(int parameterIndex,
java.lang.String value)
Sets a string value to a parameter number in a statement object.
|
static final java.lang.String TIBDG_STATEMENT_PROPERTY_LONG_PREFETCH
When creating a statement, supply this property to Session.createStatement
.
Its value determines the maximum number of rows that will be prefetched from the data grid when executing
a query. This property can also be supplied to Statement.executeQuery
to override
the value that was used when the statement was created.
If not specified or a value less than or equal to 0 is specified, a default prefetch of 256 is used.
static final java.lang.String TIBDG_STATEMENT_CONSISTENCY_GLOBAL_SNAPSHOT
Statement.TIBDG_STATEMENT_PROPERTY_STRING_CONSISTENCY
in the methods Session.createStatement
and
Statement.executeQuery
.
This value will cause a global snapshot to be taken across all
nodes in the grid when a query is executed, which will then be used when iterating through the results.
A global snapshot will ensure no partially committed transactions that span multiple nodes
are observed in the query results at the cost of needing to coordinate the global
snapshot when executing the query.static final java.lang.String TIBDG_STATEMENT_CONSISTENCY_SNAPSHOT
Statement.TIBDG_STATEMENT_PROPERTY_STRING_CONSISTENCY
in the methods Session.createStatement
and
Statement.executeQuery
.
This value will cause a snapshot to be taken at each node independently when a query is executed,
which will then be used when iterating through the results.
A snapshot taken at each node does not require waiting to create a global
snapshot across the entire grid when creating the iterator but could result
in a partially committed transaction that spanned multiple nodes being
observed in the results.static final java.lang.String TIBDG_STATEMENT_PROPERTY_STRING_CONSISTENCY
When creating a statement, supply this property to Session.createStatement
.
Its value determines the consistency when executing a query and whether or not a global snapshot needs to be taken.
This property can also be supplied to Statement.executeQuery
to override
the value that was used when the statement was created.
Supported values are
Statement.TIBDG_STATEMENT_CONSISTENCY_GLOBAL_SNAPSHOT
and
Statement.TIBDG_STATEMENT_CONSISTENCY_SNAPSHOT
static final java.lang.String TIBDG_STATEMENT_PROPERTY_DOUBLE_FETCH_TIMEOUT
This value determines how long (in seconds) the application will wait for the next batch
of rows before timing out. If this property is not supplied the current timeout for the
parent Connection is used. If a value of zero is supplied then there will be no limit to
how long the application will wait.
When creating a statement, supply this property to Session.createStatement
.
This property can also be supplied to Statement.executeQuery
to override
the value that was used when the statement was created.
ResultSet executeQuery(java.util.Properties props) throws DataGridException, DataGridInvalidArgumentException
Cannot be called if there are any open resultsets on the statement object.
props
- Optional, null to omit
ResultSet
DataGridException
- in case of failuresDataGridInvalidArgumentException
long executeUpdate(java.util.Properties props) throws DataGridException, DataGridInvalidArgumentException, DataGridNotPermittedException
Statement
object, which must be an SQL
Data Manipulation Language (DML) statement, such as INSERT
.props
- Optional, null to omitDataGridException
- in case of failure to execute on the datagrid.DataGridInvalidArgumentException
- in case of null or invalid statement.DataGridNotPermittedException
- When invoked on other than a DML statement.void setDateTime(int parameterIndex, TibDateTime value) throws DataGridException
Copies the datetime parameter so that the program is allowed to free or modify it after the function returns. Note that parameter numbers start from 1. Setting the same parameter multiple times is allowed, even with different types, as long as when ExecuteQuery is called all parameters are set and have the correct types.
parameterIndex
- The parameter number to set.value
- The datetime value to set into the statement.DataGridException
- in case of failuresvoid setDouble(int parameterIndex, double value) throws DataGridException
Note that parameter numbers start from 1. Setting the same parameter multiple times is allowed, even with different types, as long as when ExecuteQuery is called all parameters are set and have the correct types.
parameterIndex
- The parameter number to set.value
- The double value to set into the statement.DataGridException
- in case of failuresvoid setLong(int parameterIndex, long value) throws DataGridException
Note that parameter numbers start from 1. Setting the same parameter multiple times is allowed, even with different types, as long as when ExecuteQuery is called all parameters are set and have the correct types.
parameterIndex
- The parameter number to set.value
- The long value to set into the statement.DataGridException
- in case of failuresvoid setOpaque(int parameterIndex, byte[] value) throws DataGridException
Copies the opaque parameter so that the program is allowed to free or modify it after the function returns. Note that parameter numbers start from 1. Setting the same parameter multiple times is allowed, even with different types, as long as when ExecuteQuery is called all parameters are set and have the correct types.
parameterIndex
- The parameter number to set.value
- The opaque value to set into the statement.DataGridException
- in case of failuresvoid setString(int parameterIndex, java.lang.String value) throws DataGridException
Note that parameter numbers start from 1. Setting the same parameter multiple times is allowed, even with different types, as long as when ExecuteQuery is called all parameters are set and have the correct types.
parameterIndex
- The parameter number to set.value
- The string value to set into the statement.DataGridException
- in case of failuresvoid setNull(int parameterIndex) throws DataGridException
Note that parameter numbers start from 1. Setting the same parameter multiple times is allowed, even with different types, as long as when ExecuteQuery is called all parameters are set and have the correct types.
parameterIndex
- The parameter number to set.DataGridException
- in case of failuresvoid clearParameters() throws DataGridException
After calling this function, all parameters must be set again before calling ExecuteQuery. A partially bound statement object may be closed without calling this function.
DataGridException
- in case of failuresResultSetMetadata getResultSetMetadata() throws DataGridException
ResultSetMetadata
DataGridException
- in case of failureslong getParameterCount() throws DataGridException
DataGridException
- in case of failuresvoid close() throws DataGridException
Note that all resultset objects must also be closed to allow for the statement's resources to also be reclaimed.
close
in interface java.lang.AutoCloseable
DataGridException
- in case of failures