JDBC Driver for Couchbase

Build 21.0.7930

Establishing a Connection

Creating a JDBC Data Source

You can create a JDBC data source to connect from your Java application. Creating a JDBC data source based on the CData JDBC Driver for Couchbase consists of three basic steps:

  • Add the driver JAR file to the classpath. The JAR file is located in the lib subfolder of the installation directory. Note that the .lic file must be located in the same folder as the JAR file.
  • Provide the driver class. For example:
  • Provide the JDBC URL. For example:

    The second format above can be used whenever there is a conflict in your application between drivers using the same URL format to ensure you are using the CData driver. The URL must start with either "jdbc:couchbase:" or "jdbc:cdata:couchbase:" and can include any of the connection properties in name-value pairs separated with semicolons.

Connecting to Couchbase

To connect to data, set the Server property to the hostname or IP address of the Couchbase server(s) you are authenticating to. If your Couchbase server is configured to use SSL, you can enable it either by using an https URL for Server (like 'https://couchbase.server'), or by setting the UseSSL property to True.

Couchbase Analytics

By default, the driver connects to the N1QL Query service. In order to connect to the Couchbase Analytics service, you will also need to set the CouchbaseService property to Analytics.

Couchbase Cloud

A few special settings are required to connect to Couchbase Cloud:

  • Set the AuthScheme to Basic
  • Set the Server option to the domain listed in the Couchbase Cloud console.
  • Enable the UseSSL option.
  • Set the ConnectionMode to Cloud
  • Set the DNSServer option to a DNS server. In most cases this should be a public DNS service like or
  • Set the SSLServerCert option to * to trust the Couchbase server certificate. You can also provide the certificate using that option or your trust store if you want the driver to validate it.

Authenticating with Couchbase

The driver supports several forms of authentication depending upon how your Couchbase Server is configured. Couchbase Cloud only accepts Standard Authentication, while Couchbase Server accepts all forms.

Authenticating with Standard Authentication

To authenticate with standard authentication, set the following:

  • AuthScheme: Use the Basic option.
  • User: The user authenticating to Couchbase.
  • Password: The password of the user authenticating to Couchbase.

Authenticating with Client Certificates

The driver supports authenticating with client certificates when SSL is enabled. To use client certificate authentication, set the following properties.

  • AuthScheme: Required. Use the SSLCertificate option.
  • SSLClientCertType: Required. The type of client certificate set within SSLClientCert.
  • SSLClientCert: Required. The client certificate in the format given by SSLClientCertType. Usually the path to your private key file.
  • SSLClientCertPassword: Optional. The password of the client certificate if it is encrypted.
  • SSLClientCertSubject: Optional. The subject of the client certificate, by default the first certificate found in the store. This is required if more than one certificate is available in the certificate store.

Authenticating with a Credentials File

You can also authenticate using using a credentials file containing multiple logins. This is included for legacy use and is not recommended when connecting to a Couchbase Server that supports role-based authentication.

  • AuthScheme: Use the CredentialsFile option.
  • CredentialsFile; The path to the credentials file. Refer to Couchbase's documentation for more information on the format of this file.

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7930