|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.datastax.driver.core.Query
com.datastax.driver.core.BoundStatement
public class BoundStatement
A prepared statement with values bound to the bind variables.
Once a BoundStatement has values for all the variables of the PreparedStatement
it has been created from, it can executed (through Session.execute(java.lang.String)).
The values of a BoundStatement can be set by either index or name. When
setting them by name, names follow the case insensitivity rules explained in
ColumnDefinitions. Noteworthily, if multiple bind variables
correspond to the same column (as would be the case if you prepare
SELECT * FROM t WHERE x > ? AND x < ?), you will have to set
values by indexes (or the bind(java.lang.Object...) method) as the methods to set by
name only allows to set the first prepared occurrence of the column.
| Constructor Summary | |
|---|---|
BoundStatement(PreparedStatement statement)
Creates a new BoundStatement from the provided prepared
statement. |
|
| Method Summary | ||
|---|---|---|
BoundStatement |
bind(Object... values)
Bound values to the variables of this statement. |
|
ByteBuffer |
getRoutingKey()
The routing key for this bound query. |
|
boolean |
isReady()
Returns whether all variables have been bound to values in thi BoundStatement. |
|
boolean |
isSet(int i)
Returns whether the ith variable has been bound to a value. |
|
boolean |
isSet(String name)
Returns whether the (first occurrence of) variable name has been bound to a value. |
|
PreparedStatement |
preparedStatement()
Returns the prepared statement on which this BoundStatement is based. |
|
BoundStatement |
setBool(int i,
boolean v)
Set the ith value to the provided boolean. |
|
BoundStatement |
setBool(String name,
boolean v)
Set the value for (the first occurrence of) column name to the provided boolean. |
|
BoundStatement |
setBytes(int i,
ByteBuffer v)
Set the ith value to the provided byte buffer. |
|
BoundStatement |
setBytes(String name,
ByteBuffer v)
Set the value for (the first occurrence of) column name to the provided byte buffer. |
|
BoundStatement |
setBytesUnsafe(int i,
ByteBuffer v)
Set the ith value to the provided byte buffer. |
|
BoundStatement |
setBytesUnsafe(String name,
ByteBuffer v)
Set the value for (the first occurrence of) column name to the provided byte buffer. |
|
BoundStatement |
setDate(int i,
Date v)
Set the ith value to the provided date. |
|
BoundStatement |
setDate(String name,
Date v)
Set the value for (the first occurrence of) column name to the provided date. |
|
BoundStatement |
setDecimal(int i,
BigDecimal v)
Set the ith value to the provided big decimal. |
|
BoundStatement |
setDecimal(String name,
BigDecimal v)
Set the value for (the first occurrence of) column name to the provided big decimal. |
|
BoundStatement |
setDouble(int i,
double v)
Set the ith value to the provided double. |
|
BoundStatement |
setDouble(String name,
double v)
Set the value for (the first occurrence of) column name to the provided double. |
|
BoundStatement |
setFloat(int i,
float v)
Set the ith value to the provided float. |
|
BoundStatement |
setFloat(String name,
float v)
Set the value for (the first occurrence of) column name to the provided float. |
|
BoundStatement |
setInet(int i,
InetAddress v)
Set the ith value to the provided inet address. |
|
BoundStatement |
setInet(String name,
InetAddress v)
Set the value for (the first occurrence of) column name to the provided inet address. |
|
BoundStatement |
setInt(int i,
int v)
Set the ith value to the provided integer. |
|
BoundStatement |
setInt(String name,
int v)
Set the value for (the first occurrence of) column name to the provided integer. |
|
|
setList(int i,
List<T> v)
Set the ith value to the provided list. |
|
|
setList(String name,
List<T> v)
Set the value for (the first occurrence of) column name to the provided list. |
|
BoundStatement |
setLong(int i,
long v)
Set the ith value to the provided long. |
|
BoundStatement |
setLong(String name,
long v)
Set the value for (the first occurrence of) column name to the provided long. |
|
|
setMap(int i,
Map<K,V> v)
Set the ith value to the provided map. |
|
|
setMap(String name,
Map<K,V> v)
Set the value for (the first occurrence of) column name to the provided map. |
|
|
setSet(int i,
Set<T> v)
Set the ith value to the provided set. |
|
|
setSet(String name,
Set<T> v)
Set the value for (the first occurrence of) column name to the provided set. |
|
BoundStatement |
setString(int i,
String v)
Set the ith value to the provided string. |
|
BoundStatement |
setString(String name,
String v)
Set the value for (the first occurrence of) column name to the provided string. |
|
BoundStatement |
setUUID(int i,
UUID v)
Set the ith value to the provided UUID. |
|
BoundStatement |
setUUID(String name,
UUID v)
Set the value for (the first occurrence of) column name to the provided UUID. |
|
BoundStatement |
setVarint(int i,
BigInteger v)
Set the ith value to the provided big integer. |
|
BoundStatement |
setVarint(String name,
BigInteger v)
Set the value for (the first occurrence of) column name to the provided big integer. |
|
| Methods inherited from class com.datastax.driver.core.Query |
|---|
disableTracing, enableTracing, getConsistencyLevel, getRetryPolicy, isTracing, setConsistencyLevel, setRetryPolicy |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BoundStatement(PreparedStatement statement)
BoundStatement from the provided prepared
statement.
statement - the prepared statement from which to create a t BoundStatement.| Method Detail |
|---|
public PreparedStatement preparedStatement()
public boolean isReady()
public boolean isSet(int i)
ith variable has been bound to a value.
i - the index of the variable to check.
ith variable has been bound to a value.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().public boolean isSet(String name)
name has been bound to a value.
name - the name of the variable to check.
name has been bound to a value.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).public BoundStatement bind(Object... values)
BoundStatement in one call.
values - the values to bind to the variables of the newly created
BoundStatement. The first element of values will be bound to the
first bind variable, etc.. It is legal to provide less values than the
statement has bound variables. In that case, the remaining variable need
to be bound before execution. If more values than variables are provided
however, an IllegalArgumentException wil be raised.
IllegalArgumentException - if more values are 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 ByteBuffer getRoutingKey()
This method will return a non-null value if:
BoundStatement. The routing key will then be
built using the values provided for these partition key columns.PreparedStatement.setRoutingKey(java.nio.ByteBuffer)
for the PreparedStatement this statement has been built from.null is returned.
Note that if the routing key has been set through PreparedStatement.setRoutingKey(java.nio.ByteBuffer),
that value takes precedence even if the partition key is part of the bound variables.
getRoutingKey in class Querynull.
public BoundStatement setBool(int i,
boolean v)
ith value to the provided boolean.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not of type BOOLEAN.
public BoundStatement setBool(String name,
boolean v)
name to the provided boolean.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column name is not of type BOOLEAN.
public BoundStatement setInt(int i,
int v)
ith value to the provided integer.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not of type INT.
public BoundStatement setInt(String name,
int v)
name to the provided integer.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column i is not of type INT.
public BoundStatement setLong(int i,
long v)
ith value to the provided long.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is of type BIGINT or COUNTER.
public BoundStatement setLong(String name,
long v)
name to the provided long.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column i is of type BIGINT or COUNTER.
public BoundStatement setDate(int i,
Date v)
ith value to the provided date.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not of type TIMESTAMP.
public BoundStatement setDate(String name,
Date v)
name to the provided date.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column name is not of type TIMESTAMP.
public BoundStatement setFloat(int i,
float v)
ith value to the provided float.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not of type FLOAT.
public BoundStatement setFloat(String name,
float v)
name to the provided float.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column i is not of type FLOAT.
public BoundStatement setDouble(int i,
double v)
ith value to the provided double.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not of type DOUBLE.
public BoundStatement setDouble(String name,
double v)
name to the provided double.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column i is not of type DOUBLE.
public BoundStatement setString(int i,
String v)
ith value to the provided string.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is of neither of the
following types: VARCHAR, TEXT or ASCII.
public BoundStatement setString(String name,
String v)
name to the provided string.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column name is of neither of the
following types: VARCHAR, TEXT or ASCII.
public BoundStatement setBytes(int i,
ByteBuffer v)
ith value to the provided byte buffer.
This method validate that the type of the column set is BLOB. If you
want to insert manually serialized data into columns of another type,
use setBytesUnsafe(int, java.nio.ByteBuffer) instead.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not of type BLOB.
public BoundStatement setBytes(String name,
ByteBuffer v)
name to the provided byte buffer.
This method validate that the type of the column set is BLOB. If you
want to insert manually serialized data into columns of another type,
use setBytesUnsafe(int, java.nio.ByteBuffer) instead.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column name is not of type BLOB.
public BoundStatement setBytesUnsafe(int i,
ByteBuffer v)
ith value to the provided byte buffer.
Contrarily to setBytes(int, java.nio.ByteBuffer), this method does not check the
type of the column set. If you insert data that is not compatible with
the type of the column, you will get an InvalidQueryException at
execute time.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
public BoundStatement setBytesUnsafe(String name,
ByteBuffer v)
name to the provided byte buffer.
Contrarily to setBytes(int, java.nio.ByteBuffer), this method does not check the
type of the column set. If you insert data that is not compatible with
the type of the column, you will get an InvalidQueryException at
execute time.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
public BoundStatement setVarint(int i,
BigInteger v)
ith value to the provided big integer.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not of type VARINT.
public BoundStatement setVarint(String name,
BigInteger v)
name to the provided big integer.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column name is not of type VARINT.
public BoundStatement setDecimal(int i,
BigDecimal v)
ith value to the provided big decimal.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not of type DECIMAL.
public BoundStatement setDecimal(String name,
BigDecimal v)
name to the provided big decimal.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column name is not of type DECIMAL.
public BoundStatement setUUID(int i,
UUID v)
ith value to the provided UUID.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not of type UUID or
TIMEUUID, or if columm i is of type TIMEUUID but v is
not a type 1 UUID.
public BoundStatement setUUID(String name,
UUID v)
name to the provided UUID.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column name is not of type UUID or
TIMEUUID, or if columm name is of type TIMEUUID but v is
not a type 1 UUID.
public BoundStatement setInet(int i,
InetAddress v)
ith value to the provided inet address.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not of type INET.
public BoundStatement setInet(String name,
InetAddress v)
name to the provided inet address.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column name is not of type INET.
public <T> BoundStatement setList(int i,
List<T> v)
ith value to the provided list.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not a list type or
if the elements of v are not of the type of the elements of
column i.
public <T> BoundStatement setList(String name,
List<T> v)
name to the provided list.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column name is not a list type or
if the elements of v are not of the type of the elements of
column name.
public <K,V> BoundStatement setMap(int i,
Map<K,V> v)
ith value to the provided map.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not a map type or
if the elements (keys or values) of v are not of the type of the
elements of column i.
public <K,V> BoundStatement setMap(String name,
Map<K,V> v)
name to the provided map.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column name is not a map type or
if the elements (keys or values) of v are not of the type of the
elements of column name.
public <T> BoundStatement setSet(int i,
Set<T> v)
ith value to the provided set.
i - the index of the variable to set.v - the value to set.
IndexOutOfBoundsException - if i < 0 || i >= this.preparedStatement().variables().size().
InvalidTypeException - if column i is not a set type or
if the elements of v are not of the type of the elements of
column i.
public <T> BoundStatement setSet(String name,
Set<T> v)
name to the provided set.
name - the name of the variable to set (if multiple variables
name are prepared, only the first one is set).v - the value to set.
IllegalArgumentException - if name is not a prepared
variable, i.e. if !this.preparedStatement().variables().names().contains(name).
InvalidTypeException - if column name is not a set type or
if the elements of v are not of the type of the elements of
column name.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||