public abstract class AbstractSession extends Object implements Session, AsyncInitSession
Session.State
Constructor and Description |
---|
AbstractSession() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Initiates a shutdown of this session instance and blocks until
that shutdown completes.
|
ResultSet |
execute(Statement statement)
Executes the provided query.
|
ResultSet |
execute(String query)
Executes the provided query.
|
ResultSet |
execute(String query,
Object... values)
Executes the provided query using the provided value.
|
ResultSetFuture |
executeAsync(String query)
Executes the provided query asynchronously.
|
ResultSetFuture |
executeAsync(String query,
Object... values)
Executes the provided query asynchronously using the provided values.
|
PreparedStatement |
prepare(RegularStatement statement)
Prepares the provided query.
|
PreparedStatement |
prepare(String query)
Prepares the provided query string.
|
ListenableFuture<PreparedStatement> |
prepareAsync(RegularStatement statement)
Prepares the provided query asynchronously.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initAsync
closeAsync, executeAsync, getCluster, getLoggedKeyspace, getState, init, isClosed, prepareAsync
public ResultSet execute(String query)
execute(new SimpleStatement(query))
.public ResultSet execute(String query, Object... values)
execute(new SimpleStatement(query, values))
.execute
in interface Session
query
- the CQL query to execute.values
- values required for the execution of query
. See
SimpleStatement.SimpleStatement(String, Object...)
for more detail.public ResultSet execute(Statement statement)
public ResultSetFuture executeAsync(String query)
executeAsync(new SimpleStatement(query))
.executeAsync
in interface Session
query
- the CQL query to execute.public ResultSetFuture executeAsync(String query, Object... values)
executeAsync(new SimpleStatement(query, values))
.executeAsync
in interface Session
query
- the CQL query to execute.values
- values required for the execution of query
. See
SimpleStatement.SimpleStatement(String, Object...)
for more detail.public PreparedStatement prepare(String query)
public PreparedStatement prepare(RegularStatement statement)
prepare(statement.getQueryString())
,
but note that the resulting PreparedStatement
will inherit the query properties
set on statement
. Concretely, this means that in the following code:
RegularStatement toPrepare = new SimpleStatement("SELECT * FROM test WHERE k=?").setConsistencyLevel(ConsistencyLevel.QUORUM); PreparedStatement prepared = session.prepare(toPrepare); session.execute(prepared.bind("someValue"));the final execution will be performed with Quorum consistency. Please note that if the same CQL statement is prepared more than once, all calls to this method will return the same
PreparedStatement
object
but the method will still apply the properties of the prepared
Statement
to this object.public ListenableFuture<PreparedStatement> prepareAsync(RegularStatement statement)
prepareAsync(statement.getQueryString())
,
but with the additional effect that the resulting PreparedStatement
will inherit the query properties set on statement
.
Please note that if the same CQL statement is prepared more than once, all
calls to this method will return the same PreparedStatement
object
but the method will still apply the properties of the prepared
Statement
to this object.prepareAsync
in interface Session
statement
- the statement to preparestatement
.Session.prepare(RegularStatement)
public void close()
closeAsync().get()
.
Note that this method does not close the corresponding Cluster
instance (which holds additional resources, in particular internal
executors that must be shut down in order for the client program to
terminate).
If you want to do so, use Cluster.close()
, but note that it will
close all sessions created from that cluster.