Establishing a Connection
You can create and manage connections with the Data Explorer and the FireDAC Connection Editor wizards. See Connection Definitions for more information on creating connections from code and creating persistent, private, or temporary connections.
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.
By default, the component 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.
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 188.8.131.52 or 184.108.40.206.
- 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 component to validate it.
Authenticating with Couchbase
The component 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 component 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.
Using the FireDAC Connection Editor
Complete the following steps to use the FireDAC Connection Editor to assign a Couchbase connection to a TFDConnection object:
- Open a project and drop a TFDPhysCDataCouchbaseDriverLink from the Tool Palette onto the Form Designer.
- Drop a TFDConnection object onto the Form Designer.
- Double-click the TFDConnection and select CDataCouchbase in the Driver Id menu.
- Define the necessary connection properties.
- To execute ad-hoc SQL statements based on this connection, enter SQL commands on the SQL Script tab.
- In the Form Designer, select the TFDConnection object and set the Connected property to true.
Using the Data Explorer
Complete the following steps to use the Data Explorer to define persistent connections that can be shared across applications and projects:
- Click View > Tool Windows > Data Explorer in RAD Studio and expand the FireDAC node.
- Right-click the CData Couchbase Data Source node and click Add New Connection.
- Enter a name for the connection. The FireDAC Connection Editor opens.
Working with Persistent Connections
The connections you define in the Data Explorer can be assigned to a TFDConnection object by specifying the connection name in the TFDConnection object's ConnectionDefName property.
Browsing Data and Metadata
The Data Explorer also provides options for browsing Couchbase objects at design time:
- Expand the CData Couchbase Data Source node in the Data Explorer to view the defined connections.
- Expand a connection node to find the database objects available for a connection.
- Drill down to a database object to find metadata such as primary keys.
- To display data, double-click a table or view or right-click and click View.