Java CouchDB Connectivity
We can connect to the CouchDB with the Java Programming language. To connect, we are using Ektorp library that provides a persistence layer on the top of CouchDB.
Here, we are explaining an example, in which we are connecting, creating database etc.
This example is created in NetBeans IDE 8.2.
First create a maven project and then follow the following steps.
Providing a name for our project.
After finishing, see, it has a pom.xml file. We need to add dependency in this file. let's do it first.
// Ektorp library dependecy
After adding dependency, create a Java file for connection. Our Java file contains the necessary connection code .
Our project looks like this:
Now before executing Java code, check the CouchDB connection is working or not. To check it follow this URL http://localhost:5984/_utils/. It will display all the available databases.
This screen-shot shows the CouchDB index web page.
Now, execute the Java code that will create a database. We can see that database in the databases list shown at the index web page.
Check the CouchDB index web page.
See, there is three databases including javatpoint new one. It contains a document light shown as below.
Well, we have seen, how to connect and create database. Now, we can perform other database operations as well.