Search code examples
couchbasecouchbase-java-client

openBucket("bucketName", "bucketPassword") Migrating Couchbase java client from SDK 2 to SDK 3


We used Couchbase java-client version 2.7.20 in our project, now as a part of migration of JDK11 -> JDK17, we want to migrate Couchbase client also to the latest version, which is 3.3.2

But I could not figure it out how to deal with openBucket which takes two arguments in SDK3, I read documentation from Couchbase about migration, but there explained migration of openBucket with only 1 argument name, but without password argument

here is sample from our existing project code, openBucket(bucketName, bucketPassword)

@Bean(name = "exampleBucket")
    public Bucket exampleBucket() {
        return getCouchbaseCluster().openBucket("bucket_name", "bucket_password");
    }

//getCouchbaseCluster() -> custom method that creates and returns Cluster

Solution

  • In Couchbase SDK 3, the openBucket method takes only the bucket name. Authorization is handled by role-based access control. Instead of specifying a password for the bucket, you specify a username and password when connecting to the cluster.