Getting started with Java and the CouchDB API.


Ektorp provides a persistence layer on top of CouchDb with JSON processing provided by the excellent Jackson JSON library. The goal of Ektorp is to combine JPA-like functionality with the simplicity and flexibility that CouchDB provides.

See Ektorp project at Github. Or take a look at the Reference Documentation


Relax was born out of necessity of building a scalable and flexible persistence model on top of CouchDB for a startup company. The API was build from real usage patterns which were extracted from real use cases. I wanted to ensure that the API is consistent and pleasant to use.

See JRelax project at github.



jcouchdb is a new java5 CouchDB driver which allows you to choose your favourite style of combining Java and CouchDB. From totally schema-less, collections-based Documents to a graph of your own java objects or something in between.

See the jcouchdb project at google code for more details.


DroidCouch is a minimal Android library for using CouchDB, licensed under the MIT license. The intention is to make a small Java library well suited for Android mobile development.

See DroidCouch at GitHub for more details.


CouchDB4J is an updated Java library for CouchDB. It handles the REST style calls to the CouchDB server behind the scenes, and give you a handle on the JSON objects directly. CouchDB4J uses JSON-lib to handle mapping to/from JSON objects, which makes getting/setting properties on the objects very easy. You can even map Java objects to JSON objects and back to make the process easier.

With CouchDB4J, you create a Session object that handles the CouchDB server communication. From here, you can get a handle on your Database. From the Database you can run views or retrieve Documents. A ViewResult is a special type of Document which contains the id's of the Documents that matched your view function.


Sample Usage

Session s = new Session("localhost",5984);
Database db = s.getDatabase("foodb");

Document doc = db.getDocument("documentid1234");

Document newdoc = new Document();
newdoc.put("foo","baz"); // same as JSON: { foo: "baz"; }
db.saveDocument(newdoc); // auto-generated id given by the database

// Running a view
ViewResults result = db.getAllDocuments(); // same as db.view("_all_dbs");
for (Document d: result.getResults()) {

                ViewResults may not actually contain the full document, only what the view
                returned.  So, in order to get the full document, you need to request a
                new copy from the database.

        Document full = db.getDocument(d.getId());

// Ad-Hoc view
ViewResults resultAdHoc = db.adhoc("function (doc) { if ('bar') { return doc; }}");


LightCouch aims at providing a simple and easy-to-use APIs for CouchDB.

It offers a reliable and lightweight persistence interface with minimal setup and code dependency.

Visit the website at for a Getting Started guide and check out the source code on Github.

Older Libraries

Older CouchDB Java library (doesn't support newer JSON syntax):

Getting_started_with_Java (last edited 2011-11-23 14:43:07 by 62)