Using a Connection String

For some applications, you might need to use a connection string to connect to your data source. For detailed information about how to use a connection string in an ODBC application, refer to the documentation for the application that you are using.

The connection strings in the following sections are examples showing the minimum set of connection attributes that you must specify to successfully connect to the data source. Depending on the configuration of the data source and the type of connection you are working with, you might need to specify additional connection attributes. For detailed information about all the attributes that you can use in the connection string, Driver Configuration Options on page 1.

DSN Connection String Example

The following is an example of a connection string for a connection that uses a DSN:

DSN=[DataSourceName]

[DataSourceName] is the DSN that you are using for the connection.

You can set additional configuration options by appending key-value pairs to the connection string. Configuration options that are passed in using a connection string take precedence over configuration options that are set in the DSN.

DSN-less Connection String Examples

Some applications provide support for connecting to a data source using a connector without a DSN. To connect to a data source without using a DSN, use a connection string instead.

Important:

Important:

When you connect to the data store using a DSN-less connection string, the connector does not encrypt your credentials.

The placeholders in the examples are defined as follows, in alphabetical order:

  • [Credentials] is the JSON string that specifies credentials for authenticating to the Couchbase Server instance.
  • [CredFilePath] is the full path of a JSON file that contains credentials for authenticating to the Couchbase Server instance.
  • [PortNumber] is the number of the TCP port that the Couchbase Server instance uses to listen for client connections.
  • [ServerInfo] is the IP address or host name of the Couchbase Server instance to which you are connecting.

Connecting to a Couchbase Server Instance Without Authentication

Note:

When connecting to Couchbase Server version 5.0 or later, authentication is mandatory. Connections without authentication are not supported.

The following is the format of a DSN-less connection string for a Couchbase Server instance that does not require authentication:

Driver=Simba Couchbase ODBC Driver;Server=[ServerInfo];
Port=[PortNumber];

For example:

Driver=Simba Couchbase ODBC Driver;Server=192.168.222.160;
Port=8093;

Connecting to a Couchbase Server Instance Using a Credentials String

The following is the format of a DSN-less connection string that uses a credentials string to authenticate the connection:

Driver=Simba Couchbase ODBC Driver;Server=[ServerInfo];
Port=[PortNumber];AuthMech=1;CredString=[Credentials];

For example:

Driver=Simba Couchbase ODBC Driver;Server=192.168.222.160;
Port=8093;AuthMech=1;CredString=[{"user": "JSmith", "pass":"access123"}, {"user": "Admin", "pass":"simba123"}];

Connecting to a Couchbase Server Instance Using a Credentials File

The following is the format of a DSN-less connection string that uses a credentials file to authenticate the connection:

Driver=Simba Couchbase ODBC Driver;Server=[ServerInfo];
Port=[PortNumber];AuthMech=2;CredFile=[CredFilePath];

For example:

Driver=Simba Couchbase ODBC Driver;Server=192.168.222.160;
Port=8093;AuthMech=2;CredFile=C:\creds.json;