You can connect to specific Couchbase buckets (in place of using
the default bucket, or a hostname/port combination configured on
the Couchbase cluster) by using the Couchbase
URI for one or more Couchbase nodes, and
specifying the bucket name and password (if required) when
creating the new CouchbaseClient object.
For example, to connect to the local host and the
default bucket:
List<URI> uris = new LinkedList<URI>(); uris.add(URI.create("http://127.0.0.1:8091/pools")); try { client = new CouchbaseClient(uris, "default", ""); } catch (Exception e) { System.err.println("Error connecting to Couchbase: " + e.getMessage()); System.exit(0); }
The format of this constructor is:
CouchbaseClient(URIs,BUCKETNAME,BUCKETPASSWORD)Where:
URIS is a List of URIs
to the Couchbase nodes. The format of the URI is the hostname,
port and path /pools.
BUCKETNAME is the name of the bucket on the
cluster that you want to use. Specified as a
String.
BUCKETPASSWORD is the password for this
bucket. Specified as a String.
The returned CouchbaseClient object can be used
as with any other CouchbaseClient object.