public class PreparedStatement extends Object
A prepared statement can be executed once concrete values have been provided
for the bound variables. A prepared statement and the values for its
bound variables constitute a BoundStatement and can be executed (by
|Modifier and Type||Method and Description|
Creates a new BoundStatement object and bind its variables to the provided values.
Returns the default consistency level set through
Returns the keyspace at the time that this prepared statement was prepared, (that is the one on which this statement applies unless it specified a keyspace explicitly).
Returns the string of the query that was prepared to yield this
Returns metadata on the bounded variables of this prepared statement.
Sets a default consistency level for all bound statements created from this prepared statement.
Sets the routing key for this query.
Sets the routing key for this prepared statement.
public ColumnDefinitions getVariables()
public BoundStatement bind(Object... values)
This method is a convenience method for
While the number of
values cannot be greater than the number of bound
variables, the number of
values may be fewer than the number of bound
variables. In that case, the remaining variables will have to be bound
to values by another mean because the resulting
values- the values to bind to the variables of the newly created BoundStatement.
BoundStatementwith its variables bound to
IllegalArgumentException- if more
valuesare provided than there is of bound variables in this statement.
InvalidTypeException- if any of the provided value is not of correct type to be bound to the corresponding bind variable.
public PreparedStatement setRoutingKey(ByteBuffer routingKey)
While you can provide a fixed routing key for all executions of this prepared statement with this method, it is not mandatory to provide one through this method. This method should only be used if the partition key of the prepared query is not part of the prepared variables (that is if the partition key is fixed).
Note that if the partition key is part of the prepared variables, the routing key will be automatically computed once those variables are bound.
routingKey- the raw (binary) value to use as routing key.
public PreparedStatement setRoutingKey(ByteBuffer... routingKeyComponents)
setRoutingKey(ByteBuffer) for more information. This
method is a variant for when the query partition key is composite and
the routing key must be built from multiple values.
routingKeyComponents- the raw (binary) values to compose to obtain the routing key.
public PreparedStatement setConsistencyLevel(ConsistencyLevel consistency)
If no consistency level is set through this method, the bound statement created from this object will use the default consistency level (ONE).
Changing the default consistency level is not retroactive, it only applies to BoundStatement created after the change.
consistency- the default consistency level to set.
public ConsistencyLevel getConsistencyLevel()
nullif no consistency level has been set through this object
public String getQueryString()
Note that a CQL3 query may be implicitly applied to the current keyspace
(that is, if the keyspace is not explicitly qualified in the query
itself). For prepared queries, the current keyspace used is the one at
the time of the preparation, not the one at execution time. The current
keyspace at the time of the preparation can be retrieved through
public String getQueryKeyspace()
nullif no keyspace was set when the query was prepared (which is possible since keyspaces can be explicitly qualified in queries and so may not require a current keyspace to be set).
Copyright © 2013. All Rights Reserved.