Interface PreparedStatement
-
- All Superinterfaces:
Statement
- All Known Subinterfaces:
BoundStatement
public interface PreparedStatement extends Statement
Represents a
Statement
that has been compiled and an execution plan generated for it. A PreparedStatement should be used when it is expected that the same statement will be executed multiple times. This way, the cost of compilation is paid only once.An instance of PreparedStatement can be created via the
KVStore.prepare(String statement)
method. This instance can then be executed multiple times via one of the KVStore.execute methods (for example,KVStore.execute(String statement, ExecuteOptions options)
orKVStore.executeSync(Statement statement, ExecuteOptions options)
).If the statement is a DML statement that contains external variables, these variables must be bound to specific values before the statement can be executed. To allow for potentially concurrent execution of the same PreparedStatement multiple times with different bind values each time, binding of external variables must be done via one or more instances of the
BoundStatement
interface. Such instances are created via the #createBoundStatement() method. It is then the BoundStatement instances that must be executed (i.e., passed as input to the KVStore execute methods) instead of the PreparedStatement instanceObjects implementing the PreparedStatement interface are thread-safe and their methods are re-entrant. On the other hand,
BoundStatement
instances are not thread-safe.- Since:
- 4.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BoundStatement
createBoundStatement()
Creates a new BoundStatement object for this PreparedStatement.RecordDef
getResultDef()
Returns the definition of the result of this Statement.FieldDef
getVariableType(String variableName)
Returns the type of the given variableName ornull
if it doesn't exist.Map<String,FieldDef>
getVariableTypes()
Returns the types of the variables.
-
-
-
Method Detail
-
getResultDef
RecordDef getResultDef()
Returns the definition of the result of this Statement.
-
getVariableType
FieldDef getVariableType(String variableName)
Returns the type of the given variableName ornull
if it doesn't exist.
-
createBoundStatement
BoundStatement createBoundStatement()
Creates a new BoundStatement object for this PreparedStatement.
-
-