Sample code for configuration class for Couchbase 5.1 java sdk

Hi Team,
We were using Couchbase 4.6 till now which requires only bucket name, bucket password and cluster name but we are migrating to couchbase 5.1 now which has couchbase username, password, bucket name and cluster name
In the enterprise level we need do all these changes but i am.getting some error while running the configuration for 5.1 after doing all the required changes.
Can someone please provide sample code for configuration class for Couchbase 5.1 java sdk.

Hi @kriteshmehra,

Check out “Start Using the SDK” in the documentation. For Java, start here:

Hi Matthew,

Can you also help me out for on how to use n1ql query for complex queries using java sdk.


Hi @kriteshmehra,

There’s also an example of how to use the Java SDK to run N1QL queries at that same link:

 // Perform a N1QL Query
        N1qlQueryResult result = bucket.query(
            N1qlQuery.parameterized("SELECT name FROM `bucketname` WHERE $1 IN interests",
            JsonArray.from("African Swallows"))

        // Print each found Row
        for (N1qlQueryRow row : result) {
            // Prints {"name":"Arthur"}

If you have a question about a specific N1QL query, I’d recommend the N1QL forum: Or, if you already have a N1QL query you want to use, and are having trouble with the Java SDK, you can definitely ask here (I’d recommend starting another forum thread).