Elffuss BraidHub

kikocis/java-driver public

6ad0d047bddb · 2.7 KiBSourceRawPermalink

Statements

To execute a query, you create a Statement instance and pass it to Session#execute(). The driver provides various implementations:

Session also has a shortcut to build and execute a simple statement in a single call:

session.execute("select release_version from system.local");

// Is equivalent to:
Statement s = new SimpleStatement("select release_version from system.local");
session.execute(s);

Customizing execution

Before executing a statement, you might want to customize certain aspects of its execution. Statement provides a number of methods for this, for example:

Statement s = new SimpleStatement("select release_version from system.local");
s.enableTracing();
session.execute(s);

If you use custom policies (RetryPolicy, LoadBalancingPolicy, SpeculativeExecutionPolicy...), you might also want to have custom properties that influence statement execution. To achieve this, you can wrap your statements in a custom StatementWrapper implementation.