N
N
Nikolay Baranenko2017-01-15 14:40:22
Java
Nikolay Baranenko, 2017-01-15 14:40:22

How to connect in Java to CouchDB?

Hello.
Recently I decided to try the CouchDB DBMS.
Initially, the installation was on localhost:5984/_utils.
Then I changed its port to 2006, created a couchdb DB for tests, and came up with a name and password.
Now there was a desire to write a client in Java
Connected libraries
couchbase-core-io-1.4.0.jar
couchbase-java-client-2.4.0.jar
rxjava-1.2.3.jar
tried to connect like this

String Name = "dbcouch";
                String Password = "password";
                String BucketName="couchdb";

                DefaultCouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder().build();
                CouchbaseCluster cluster = CouchbaseCluster.create(env, "192.168.10.12:2006");
                ClusterManager clusterManager = cluster.clusterManager(Name, Password);

                if (clusterManager.hasBucket(BucketName)) {
                    BucketSettings bucketSettings = clusterManager.getBucket(BucketName);
                    Bucket bucket = cluster.openBucket(BucketName, "");
                    bucket.close();
                }

                cluster.disconnect();

BUT I get an error
exception: java.lang.RuntimeException: com.couchbase.client.deps.io.netty.channel.ConnectTimeoutException: connection timed out: DESKTOP-PC/192.168.56.1:8091

I suspect I'm doing something wrong.
Please advise where is the error and how to solve it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2017-09-17
@avsej

Couchbase != CouchDB. They are completely different databases. In your case, you need to either install Couchbase Server instead of CouchDB or change client libraries.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question