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.
|
com.google.common.util.concurrent.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)
This is a convenience method for 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)
This method is essentially a shortcut for 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 com.google.common.util.concurrent.ListenableFuture<PreparedStatement> prepareAsync(RegularStatement statement)
This method is essentially a shortcut for 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()
This method is a shortcut for 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.
Copyright © 2012–2015. All rights reserved.