Name Date Size

..22-Jun-20214 KiB

.gitignoreH A D11-Feb-2020294

.mailmapH A D11-Feb-2020432

config/checkstyle/H11-Feb-20204 KiB

CONTRIBUTING.mdH A D11-Feb-202011 KiB

docs/H11-Feb-20204 KiB

pom.xmlH A D11-Feb-202013.6 KiB

README.mdH A D11-Feb-20203.7 KiB

src/H11-Feb-20204 KiB

README.md

1# Official Couchbase Java SDK
2
3This project is the official driver for Couchbase when working with Java (or on the JVM). It provides management, CRUD and query facilities through both asynchronous and synchronous APIs.
4
5## Features ##
6
7* High-Performance Key/Value and Query (N1QL, Views) operations
8* Cluster-Awareness and automatic rebalance and failover handling
9* Asynchronous (through [RxJava](https://github.com/ReactiveX/RxJava)) and Synchronous APIs
10* Transparent Encryption Support
11* Cluster and Bucket level management facilities
12* Complete non-blocking stack through [RxJava](https://github.com/ReactiveX/RxJava) and [Netty](http://netty.io)
13
14## Getting Help ##
15This README, as well as the [reference documentation](http://developer.couchbase.com/documentation/server/4.5/sdk/java/start-using-sdk.html) are the best places to get started and dig deeper into the Couchbase SDK. In addition, you might want to look at our [travel-sample application](https://github.com/couchbaselabs/try-cb-java).
16
17The primary way to ask questions is through our official [Forums](http://forums.couchbase.com), although there is also a [stackoverflow tag](http://stackoverflow.com/questions/tagged/couchbase). You can also ask questions on `#couchbase` or `#libcouchbase` on IRC (freenode). Please file any issues you find or enhancements you want to request against our [JIRA](http://issues.couchbase.com/browse/JCBC) which we use for universal issue tracking.
18
19## Quick Start ##
20The easiest way is to download the jar as well as its transitive dependencies (only 2) through maven:
21
22
23```xml
24<dependency>
25    <groupId>com.couchbase.client</groupId>
26    <artifactId>java-client</artifactId>
27    <version>2.4.7</version>
28</dependency>
29```
30
31You can find information to older versions as well as alternative downloads [here](http://developer.couchbase.com/server/other-products/release-notes-archives/java-sdk).
32
33The following code connects to the `Cluster`, opens a `Bucket`, stores a `Document`, retrieves it and prints out parts of the content.
34
35```java
36// Create a cluster reference
37CouchbaseCluster cluster = CouchbaseCluster.create("127.0.0.1");
38
39// Connect to the bucket and open it
40Bucket bucket = cluster.openBucket("default");
41
42// Create a JSON document and store it with the ID "helloworld"
43JsonObject content = JsonObject.create().put("hello", "world");
44JsonDocument inserted = bucket.upsert(JsonDocument.create("helloworld", content));
45
46// Read the document and print the "hello" field
47JsonDocument found = bucket.get("helloworld");
48System.out.println("Couchbase is the best database in the " + found.content().getString("hello"));
49
50// Close all buckets and disconnect
51cluster.disconnect();
52```
53
54If you want to perform a N1QL query against [Couchbase Server 4.0](http://www.couchbase.com/nosql-databases/couchbase-server) or later, you can do it like this:
55
56```java
57N1qlQueryResult result = bucket.query(N1qlQuery.simple("SELECT DISTINCT(country) FROM `travel-sample` WHERE type = 'airline' LIMIT 10"));
58
59for (N1qlQueryRow row : result) {
60    System.out.println(row.value());
61}
62```
63
64This prints out the distinct countries for all airlines stored in the `travel-sample` bucket that comes with the server.
65
66If you want to learn more, check out the [Start Using the SDK](http://developer.couchbase.com/documentation/server/4.5/sdk/java/start-using-sdk.html) section in the official documentation.
67
68## Contributing ##
69
70We use Gerrit for our code review system. Please have a look at the extensive [`CONTRIBUTING.md`](CONTRIBUTING.md) for more details.
71
72Feel free to reach out to the maintainers over the forums, IRC or email if you have further questions on contributing or get stuck along the way. We love contributions and want to help you get your change over the finish line - and you mentioned in the release notes!
73