Use the unified DataStax C++ driver to connect to your DataStax Astra DB database and begin building your own application.
DataStax recommends using the unified DataStax C++ driver.If you have an existing Apache Cassandra or DataStax Enterprise (DSE) C++ driver, migrate the driver to a version that is capable of connecting to Astra databases.
- Download the secure connect bundle to obtain connection credentials for your Astra DB database.
- Client ID_ and _Client Secret by creating your application token for your username and password.
Alternatively, have a teammate provide access to their Astra database.
- Download the DataStax C++ driver and dependency packages for your platform using the links in the following table:
DataStax C++ driver download links
Platform | Download links |
---|---|
CentOS 6 | Driver | Dependencies |
CentOS 7 | Driver | Dependencies |
Ubuntu 14.04 | Driver | Dependencies |
Ubuntu 16.04 | Driver | Dependencies |
Ubuntu 18.04 | Driver | Dependencies |
Windows | Driver | Dependencies |
Other platforms should build the driver from the source code packages.
- Using the packages you downloaded, follow the installation instructions for your platform to install the DataStax C++ driver.
- Create a connect_database.c file in the main directory for your Cundefined project.
- 1
- Copy the following connection code into the connect_database.c file.The secureconnectbundle must include the absolute path to your Astra database credentials (`secure-connect-*database_name*.zip`).
The `cassclustersetcontactpoints() and casscluster_setssl() methods should not used in conjunction with the cassclusterset_cloud_secureconnectionbundle()` method.
- 1
- 2
- Build and link your application against the DataStax C++ driver.
For static linking, use cassandra_static.a .
- 1
- WindowsInclude these libraries in your Microsoft Visual Studio project by adding them to the project’s properties under ` Configuration Properties/Linker/Input/Additional Dependencies `.
For static linking, use ` cassandra_static.lib `.
Link your application against ` cassandra.lib .Your application will also require cassandra.dll to be in your runtime path.
- After connecting to your database, use the following code to query your database.This code creates a CassStatement object to connect to your Astra DB database, runs a CQL query, and prints the output to the console.
- 1
- 2
- 3