| 1 | ## Statements |
| 2 | |
| 3 | To execute a query, you create a [Statement] instance and pass it to [Session#execute()][execute] or |
| 4 | [Session#executeAsync][executeAsync]. The driver provides various implementations: |
| 5 | |
| 6 | * [SimpleStatement](simple/): a simple implementation built directly from a |
| 7 | character string. Typically used for queries that are executed only |
| 8 | once or a few times. |
| 9 | * [BoundStatement](prepared/): obtained by binding values to a prepared |
| 10 | statement. Typically used for queries that are executed |
| 11 | often, with different values. |
| 12 | * [BuiltStatement](built/): a statement built with the [QueryBuilder] DSL. It |
| 13 | can be executed directly like a simple statement, or prepared. |
| 14 | * [BatchStatement](batch/): a statement that groups multiple statements to be |
| 15 | executed as a batch. |
| 16 | |
| 17 | |
| 18 | ### Customizing execution |
| 19 | |
| 20 | Before executing a statement, you might want to customize certain |
| 21 | aspects of its execution. `Statement` provides a number of methods for |
| 22 | this, for example: |
| 23 | |
| 24 | ```java |
| 25 | Statement s = new SimpleStatement("select release_version from system.local"); |
| 26 | s.enableTracing(); |
| 27 | session.execute(s); |
| 28 | ``` |
| 29 | |
| 30 | If you use custom policies ([RetryPolicy], [LoadBalancingPolicy], |
| 31 | [SpeculativeExecutionPolicy]...), you might also want to have custom |
| 32 | properties that influence statement execution. To achieve this, you can |
| 33 | wrap your statements in a custom [StatementWrapper] implementation. |
| 34 | |
| 35 | [Statement]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/Statement.html |
| 36 | [QueryBuilder]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/querybuilder/QueryBuilder.html |
| 37 | [StatementWrapper]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/StatementWrapper.html |
| 38 | [RetryPolicy]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/policies/RetryPolicy.html |
| 39 | [LoadBalancingPolicy]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/policies/LoadBalancingPolicy.html |
| 40 | [SpeculativeExecutionPolicy]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/policies/SpeculativeExecutionPolicy.html |
| 41 | [execute]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/Session.html#execute-com.datastax.driver.core.Statement- |
| 42 | [executeAsync]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/Session.html#executeAsync-com.datastax.driver.core.Statement- |