| 1 | # Datastax Java Driver for Apache Cassandra |
| 2 | |
| 3 | [](https://travis-ci.org/datastax/java-driver) |
| 4 | |
| 5 | *If you're reading this on github.com, please note that this is the readme |
| 6 | for the development version and that some features described here might |
| 7 | not yet have been released. You can find the documentation for latest |
| 8 | version through [Java driver |
| 9 | docs](http://datastax.github.io/java-driver/) or via the release tags, |
| 10 | [e.g. |
| 11 | 3.1.4](https://github.com/datastax/java-driver/tree/3.1.4).* |
| 12 | |
| 13 | A modern, [feature-rich](manual/) and highly tunable Java client |
| 14 | library for Apache Cassandra (1.2+) and DataStax Enterprise (3.1+) using |
| 15 | exclusively Cassandra's binary protocol and Cassandra Query Language v3. |
| 16 | |
| 17 | **Features:** |
| 18 | |
| 19 | * [Sync](manual/) and [Async](manual/async/) API |
| 20 | * [Simple](manual/statements/simple/), [Prepared](manual/statements/prepared/), and [Batch](manual/statements/batch/) |
| 21 | statements |
| 22 | * Asynchronous IO, parallel execution, request pipelining |
| 23 | * [Connection pooling](manual/pooling/) |
| 24 | * Auto node discovery |
| 25 | * Automatic reconnection |
| 26 | * Configurable [load balancing](manual/load_balancing/) and [retry policies](manual/retries/) |
| 27 | * Works with any cluster size |
| 28 | * [Query builder](manual/statements/built/) |
| 29 | * [Object mapper](manual/object_mapper/) |
| 30 | |
| 31 | The driver architecture is based on layers. At the bottom lies the driver core. |
| 32 | This core handles everything related to the connections to a Cassandra |
| 33 | cluster (for example, connection pool, discovering new nodes, etc.) and exposes a simple, |
| 34 | relatively low-level API on top of which higher level layers can be built. |
| 35 | |
| 36 | The driver contains the following modules: |
| 37 | |
| 38 | - driver-core: the core layer. |
| 39 | - driver-mapping: the object mapper. |
| 40 | - driver-extras: optional features for the Java driver. |
| 41 | - driver-examples: example applications using the other modules which are |
| 42 | only meant for demonstration purposes. |
| 43 | - driver-tests: tests for the java-driver. |
| 44 | |
| 45 | **Useful links:** |
| 46 | |
| 47 | - JIRA (bug tracking): https://datastax-oss.atlassian.net/browse/JAVA |
| 48 | - MAILING LIST: https://groups.google.com/a/lists.datastax.com/forum/#!forum/java-driver-user |
| 49 | - IRC: #datastax-drivers on [irc.freenode.net](http://freenode.net) |
| 50 | - TWITTER: [@dsJavaDriver](https://twitter.com/dsJavaDriver) tweets Java |
| 51 | driver releases and important announcements (low frequency). |
| 52 | [@DataStaxEng](https://twitter.com/datastaxeng) has more news including |
| 53 | other drivers, Cassandra, and DSE. |
| 54 | - DOCS: the [manual](http://docs.datastax.com/en/developer/java-driver/3.1/manual/) has quick |
| 55 | start material and technical details about the driver and its features. |
| 56 | - API: http://www.datastax.com/drivers/java/3.1 |
| 57 | - [changelog](changelog/) |
| 58 | - [binary tarball](http://downloads.datastax.com/java-driver/cassandra-java-driver-3.1.4.tar.gz) |
| 59 | |
| 60 | **Feeback requested:** help us focus our efforts, provide your input on the [Platform and Runtime Survey](http://goo.gl/forms/qwUE6qnL7U) (we kept it short). |
| 61 | |
| 62 | ## Getting the driver |
| 63 | |
| 64 | The last release of the driver is available on Maven Central. You can install |
| 65 | it in your application using the following Maven dependency: |
| 66 | |
| 67 | ```xml |
| 68 | <dependency> |
| 69 | <groupId>com.datastax.cassandra</groupId> |
| 70 | <artifactId>cassandra-driver-core</artifactId> |
| 71 | <version>3.1.4</version> |
| 72 | </dependency> |
| 73 | ``` |
| 74 | |
| 75 | Note that the object mapper is published as a separate artifact: |
| 76 | |
| 77 | ```xml |
| 78 | <dependency> |
| 79 | <groupId>com.datastax.cassandra</groupId> |
| 80 | <artifactId>cassandra-driver-mapping</artifactId> |
| 81 | <version>3.1.4</version> |
| 82 | </dependency> |
| 83 | ``` |
| 84 | |
| 85 | The 'extras' module is also published as a separate artifact: |
| 86 | |
| 87 | ```xml |
| 88 | <dependency> |
| 89 | <groupId>com.datastax.cassandra</groupId> |
| 90 | <artifactId>cassandra-driver-extras</artifactId> |
| 91 | <version>3.1.4</version> |
| 92 | </dependency> |
| 93 | ``` |
| 94 | |
| 95 | |
| 96 | We also provide a [shaded JAR](manual/shaded_jar/) |
| 97 | to avoid the explicit dependency to Netty. |
| 98 | |
| 99 | If you can't use a dependency management tool, a |
| 100 | [binary tarball](http://downloads.datastax.com/java-driver/cassandra-java-driver-3.1.4.tar.gz) |
| 101 | is available for download. |
| 102 | |
| 103 | ## Compatibility |
| 104 | |
| 105 | The Java client driver 3.1.4 ([branch 3.1](https://github.com/datastax/java-driver/tree/3.1)) is compatible with Apache |
| 106 | Cassandra 1.2, 2.0, 2.1, 2.2 and 3.0 (see [this page](http://datastax.github.io/java-driver/manual/native_protocol) for |
| 107 | the most up-to-date compatibility information). |
| 108 | |
| 109 | UDT and tuple support is available only when using Apache Cassandra 2.1 or higher (see [CQL improvements in Cassandra 2.1](http://www.datastax.com/dev/blog/cql-in-2-1)). |
| 110 | |
| 111 | Other features are available only when using Apache Cassandra 2.0 or higher (e.g. result set paging, |
| 112 | [BatchStatement](https://github.com/datastax/java-driver/blob/3.0/driver-core/src/main/java/com/datastax/driver/core/BatchStatement.java), |
| 113 | [lightweight transactions](http://www.datastax.com/documentation/cql/3.1/cql/cql_using/use_ltweight_transaction_t.html) |
| 114 | -- see [What's new in Cassandra 2.0](http://www.datastax.com/documentation/cassandra/2.0/cassandra/features/features_key_c.html)). |
| 115 | Trying to use these with a cluster running Cassandra 1.2 will result in |
| 116 | an [UnsupportedFeatureException](https://github.com/datastax/java-driver/blob/3.0/driver-core/src/main/java/com/datastax/driver/core/exceptions/UnsupportedFeatureException.java) being thrown. |
| 117 | |
| 118 | |
| 119 | ## Upgrading from previous versions |
| 120 | |
| 121 | If you are upgrading from a previous version of the driver, be sure to have a look at |
| 122 | the [upgrade guide](/upgrade_guide/). |
| 123 | |
| 124 | |
| 125 | ### Troubleshooting |
| 126 | |
| 127 | If you are having issues connecting to the cluster (seeing `NoHostAvailableConnection` exceptions) please check the |
| 128 | [connection requirements](https://github.com/datastax/java-driver/wiki/Connection-requirements). |
| 129 | |
| 130 | |
| 131 | ## License |
| 132 | Copyright 2012-2015, DataStax |
| 133 | |
| 134 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 135 | you may not use this file except in compliance with the License. |
| 136 | You may obtain a copy of the License at |
| 137 | |
| 138 | http://www.apache.org/licenses/LICENSE-2.0 |
| 139 | |
| 140 | Unless required by applicable law or agreed to in writing, software |
| 141 | distributed under the License is distributed on an "AS IS" BASIS, |
| 142 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 143 | See the License for the specific language governing permissions and |
| 144 | limitations under the License. |