Search code examples
couchbasebucket

Connect to bucket name that named not 'default'


I have a Couchbase server and a .Net client. When I named the bucket "default" every thing run ok but when I create a bucket with another name like 'cashdb' my client got error "Null Pointer Exception".

I really don't know if you want to have 3 bucket on a server with difference names , what can you do?


Solution

  • When you have multiple buckets (or even a single bucket that's not named 'default'), you have to explicitly specify which one you want to open when creating the connection.

    In the 1.x SDK it's:

    var config = new CouchbaseClientConfiguration();
    config.Bucket = "mybucket"
    config.BucketPassword = "12345";
    var connection = new CouchbaseClient(config);
    

    In the 2.x SDK it's slightly longer, so take a look here: http://docs.couchbase.com/developer/dotnet-2.0/configuring-the-client.html