A newer version of this documentation is available.

View Latest

Buckets and Clusters

    +
    The Couchbase Java SDK provides an API for managing a Couchbase cluster programmatically.

    Unresolved include directive in modules/concept-docs/pages/buckets-and-clusters.adoc - include::6.5@sdk:shared:partial$clusters-buckets.adoc[]

    Management operations in the Java SDK may be performed through several interfaces depending on the object:

    Creating and Removing Buckets

    To create or delete a bucket, call the bucket manager with the buckets() call on the cluster:

        BucketManager manager = cluster.buckets();
        bucketSettings = BucketSettings.create("myBucket");
        manager.createBucket(bucketSettings);
        // #end::buckets_and_clusters_1[];
      }
    
      public static void main(String[] args) throws Exception {
        BucketsAndClustersExample obj = new BucketsAndClustersExample();
        obj.init();
        obj.buckets_and_clusters_1();
        System.out.println("Done.");
      }
    }

    This class is also used to expose information about an existing bucket (manager.getBucket(string)) or to update an existing bucket (manager.updateBucket(bucketSettings)).

    The default Collection & Default Scope will be used automatically.