Migrating your DataStax C++ driver to connect with Apollo databases

Migrate your existing DataStax C++ driver to a version compatible with Cassandra databases.

Complete the following procedure to migrate your existing DataStax C++ driver to a version that is capable of connecting to Apollo databases created using DataStax Apollo on Constellation.

Prerequisites

  1. Create a DataStax Apollo database.
  2. Download the secure connect bundle to obtain connection credentials for your DataStax Apollo database.
  3. Download the DataStax C++ driver and dependency packages for your platform using the links in the following table.
    Table 1. 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.
  4. Using the packages you downloaded, follow the installation instructions for your platform to install the DataStax C++ driver.

Procedure

  1. In your existing DataStax C++ driver code, modify the connection code to use the DataStax Apollo on Constellation API.
    Note: Both the DataStax C++ driver for Apache Cassandra and the DataStax Enterprise (DSE) C++ driver use the same code to connect and query your Apollo database. When using the DSE C++ driver, use the header #include <dse.h>.

    The secure_connect_bundle must include the absolute path to your Apollo database credentials (secure-connect-database_name.zip).

      cass_cluster_set_credentials(cluster, "username", "password");
    
      CassFuture* connect_future = cass_session_connect(session, cluster);
    
      if (cass_future_error_code(connect_future) == CASS_OK) {
        /* Use the session to run queries */
      } else {
        /* Handle error */
      }
    
  2. Build and link your application against the DataStax C++ driver.
    • Linux or macOS

      Note: For static linking, use cassandra_static.a or dse_static.a.

      DataStax C++ driver for Apache Cassandra

      cc connect-database.c -I/path/to/cassandra.h -L/path/to/cassandra.so -lcassandra

      DSE C++ driver

      cc connect-database.c -I/path/to/dse.h -L/path/to/dse.so -ldse
    • Windows

      Include these libraries in your Microsoft Visual Studio project by adding them to the project’s properties under Configuration Properties/Linker/Input/Additional Dependencies.

      Note: For static linking, use cassandra_static.lib or dse_static.lib.

      DataStax C++ driver for Apache Cassandra

      Link your application against cassandra.lib. Your application will also require cassandra.dll to be in your runtime path.

      DSE C++ driver

      Link your application against dse.lib. Your application will also require dse.dll to be in your runtime path.