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: https://developer.couchbase.com/documentation/server/current/sdk/java/start-using-sdk.html

Hi Matthew,

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

Thanks

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"}
            System.out.println(row);
        }

If you have a question about a specific N1QL query, I’d recommend the N1QL forum: https://www.couchbase.com/forums/c/n1ql. 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).