Connecting to Apollo (Cloud)

Using the DataStax Java Driver to connect to a DataStax Apollo database is almost identical to using the driver to connect to any normal Apache Cassandra® database. The only differences are in how the driver is configured in an application and that you will need to obtain a secure connect bundle.

The following is a Quick Start guide to writing a simple application that can connect to an Apollo database.


  1. Download and install Maven.
  2. Create an Apollo database on GCP or AWS; alternatively, have a team member provide access to their Apollo database (instructions for GCP and AWS) to obtain database connection details.
  3. Download the secure connect bundle (instructions for GCP and AWS) to obtain connection credentials for your database.


  1. Include the driver artifacts in your pom.xml file according to this pom.xml dependency.

  2. Initialize the DataStax Java Driver.

    a. Create a file in the /src/main/java directory for your Java project.

      $ cd javaProject/src/main/java
      $ touch

    b. Copy the following code for your DataStax Driver into the file.
    The following example implements a ConnectDatabase class to connect to your Apollo database, runs a CQL query, and prints the output to the console.

    Note: With the DseCluster.builder() object, make sure to set the path to the secure connect bundle for your Apollo database (“/path/to/”) in the withCloudSecureConnectBundle() method as shown in the following example.

    • DataStax Java Driver for DataStax Enterprise (DSE) 1.x

        import com.datastax.driver.core.ResultSet;
        import com.datastax.driver.core.Row;
        import com.datastax.driver.core.Session;
        import com.datastax.driver.dse.DseCluster;
        public class ConnectDatabase {
          public static void main(String[] args) {
            // Create the DseCluster object:
            DseCluster cluster = null;
            try {
              cluster = DseCluster.builder()
                // make sure you change the path to the secure connect bundle below
                .withCloudSecureConnectBundle(new File("/path/to/"))
                .withCredentials("user_name", "password")
              Session session = cluster.connect();
              // Select the release_version from the system.local table:
              ResultSet rs = session.execute("select release_version from system.local");
              Row row =;
              //Print the results of the CQL query to the console:
              if (row != null) {
              } else {
                System.out.println("An error occurred.");
            } finally {
              if (cluster != null) cluster.close();

    c. Save and close the file.

Apollo Differences

In most circumstances, the client code for interacting with an Apollo cluster will be the same as interacting with any other Cassandra cluster. The exceptions being:

  • An SSL connection will be established automatically. Manual SSL configuration is not necessary.

  • A Cluster’s contact points attribute should not be used. The cloud config contains all of the necessary contact information (i.e. don’t use any of the addContactPoint() or addContactPoints() methods on the Builder)

  • If a consistency level is not specified for an execution profile or query, then ConsistencyLevel.LOCAL_QUORUM will be used as the default.