public interface SyncCqlSession extends Session
OSS_DRIVER_COORDINATES
Modifier and Type | Method and Description |
---|---|
default ResultSet |
execute(Statement<?> statement)
Executes a CQL statement synchronously (the calling thread blocks until the result becomes
available).
|
default ResultSet |
execute(String query)
Executes a CQL statement synchronously (the calling thread blocks until the result becomes
available).
|
default PreparedStatement |
prepare(PrepareRequest request)
Prepares a CQL statement synchronously (the calling thread blocks until the statement is
prepared).
|
default PreparedStatement |
prepare(SimpleStatement statement)
Prepares a CQL statement synchronously (the calling thread blocks until the statement is
prepared).
|
default PreparedStatement |
prepare(String query)
Prepares a CQL statement synchronously (the calling thread blocks until the statement is
prepared).
|
checkSchemaAgreement, checkSchemaAgreementAsync, execute, getContext, getKeyspace, getMetadata, getMetrics, getName, isSchemaMetadataEnabled, refreshSchema, refreshSchemaAsync, setSchemaMetadataEnabled
close, closeAsync, closeFuture, forceCloseAsync, isClosed
@NonNull default ResultSet execute(@NonNull Statement<?> statement)
statement
- the CQL query to execute (that can be any Statement
).AllNodesFailedException
- if no host in the cluster can be contacted successfully to
execute this query.QueryExecutionException
- if the query triggered an execution exception, i.e. an
exception thrown by Cassandra when it cannot execute the query with the requested
consistency level successfully.QueryValidationException
- if the query is invalid (syntax error, unauthorized or any
other validation problem).@NonNull default ResultSet execute(@NonNull String query)
query
- the CQL query to execute.AllNodesFailedException
- if no host in the cluster can be contacted successfully to
execute this query.QueryExecutionException
- if the query triggered an execution exception, i.e. an
exception thrown by Cassandra when it cannot execute the query with the requested
consistency level successfully.QueryValidationException
- if the query if invalid (syntax error, unauthorized or any
other validation problem).@NonNull default PreparedStatement prepare(@NonNull SimpleStatement statement)
Note that the bound statements created from the resulting prepared statement will inherit some of the attributes of the provided simple statement. That is, given:
SimpleStatement simpleStatement = SimpleStatement.newInstance("...");
PreparedStatement preparedStatement = session.prepare(simpleStatement);
BoundStatement boundStatement = preparedStatement.bind();
Then:
simpleStatement
:
boundStatement.getExecutionProfileName()
boundStatement.getExecutionProfile()
boundStatement.getPagingState()
boundStatement.getRoutingKey()
boundStatement.getRoutingToken()
boundStatement.getCustomPayload()
boundStatement.isIdempotent()
boundStatement.getTimeout()
boundStatement.getPagingState()
boundStatement.getPageSize()
boundStatement.getConsistencyLevel()
boundStatement.getSerialConsistencyLevel()
boundStatement.isTracing()
boundStatement.getRoutingKeyspace()
is set from
either simpleStatement.getKeyspace()
(if it's not null
), or simpleStatement.getRoutingKeyspace()
;
boundStatement.getQueryTimestamp()
will be
set to Statement.NO_DEFAULT_TIMESTAMP
, meaning that the value will be
assigned by the session's timestamp generator.
boundStatement.getNode()
will always be null
.
Statement.getNowInSeconds()
boundStatement.getNowInSeconds()} will always
be equal to Statement.NO_NOW_IN_SECONDS
.
PrepareRequest
and pass it to prepare(PrepareRequest)
.
The result of this method is cached: if you call it twice with the same SimpleStatement
, you will get the same PreparedStatement
instance. We still recommend
keeping a reference to it (for example by caching it as a field in a DAO); if that's not
possible (e.g. if query strings are generated dynamically), it's OK to call this method every
time: there will just be a small performance overhead to check the internal cache. Note that
caching is based on:
statement
- the CQL query to execute (that can be any SimpleStatement
).statement
.SyntaxError
- if the syntax of the query to prepare is not correct.@NonNull default PreparedStatement prepare(@NonNull String query)
The result of this method is cached (see prepare(SimpleStatement)
for more
explanations).
query
- the CQL string query to execute.query
.SyntaxError
- if the syntax of the query to prepare is not correct.@NonNull default PreparedStatement prepare(@NonNull PrepareRequest request)
This variant is exposed in case you use an ad hoc PrepareRequest
implementation to
customize how attributes are propagated when you prepare a SimpleStatement
(see prepare(SimpleStatement)
for more explanations). Otherwise, you should rarely have to deal
with PrepareRequest
directly.
The result of this method is cached (see prepare(SimpleStatement)
for more
explanations).
request
- the PrepareRequest
to execute.request
.SyntaxError
- if the syntax of the query to prepare is not correct.Copyright © 2017–2024. All rights reserved.