Building an application for the DataStax Distribution of Apache Cassandra

Building an application for DDAC.

You can build an application to connect to your DataStax Distribution of Apache Cassandra™ (DDAC) cluster using any of the drivers for Apache Cassandra™, including Java, Python, C++, C#, Node.js, Ruby, and PHP.

These steps demonstrate how to create a simple Java application using version 3.7.1 of the DataStax Java Driver for Apache Cassandra™.
Note: There are API changes for newer versions of the Java driver (4.0+), which impact this process. To follow these steps, use version 3.7.1.

For a detailed video demonstration, watch our DataStax Distribution of Apache Cassandra™ on Microsoft Azure video series.


  1. Set your deployment to use public IPs for your nodes.
  2. Download the Java driver from Github and add to your CLASSPATH.
    Alternatively, add the following dependency to your Maven POM file:
  3. Create a Cluster object using the Cluster.builder() helper class.
    Cluster cluster = Cluster.builder().addContactPoint("").build();
    1. Replace the IP address shown in addContactPoint() with the public IP of the node in your deployment, shown as nodePubIp in the deployment Outputs tab.

    The Cluster object is the starting point to connect to a Cassandra cluster.

  4. Create a Session object.
    Session session = cluster.connect();
    The driver makes connections to the cluster nodes.
  5. Using the Session object, execute statements with execute() to run CQL statements.
    1. Create the data model with the killrvideo keyspace and a videostable.
      Note: DataStax recommends creating the data model outside of the application.
      session.execute("CREATE KEYSPACE IF NOT EXISTS killrvideo WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};");
      session.execute("CREATE TABLE IF NOT EXISTS killrvideo.videos (name TEXT, description TEXT, PRIMARY KEY(name))");
    2. Insert a row into the videos table.
      session.execute("INSERT INTO killrvideo.videos (name, description) VALUES (?, ?);", "Avengers: Endgame", "No spoilers");
    3. Run a query, which returns a ResultSet object.
      ResultSet rs = session.execute("SELECT * FROM killrvideo.videos WHERE name = ?;", "Avengers: Endgame");
      for (Row row : rs) {
        System.out.println("Name:" + row.getString("name"));
        System.out.println("Description: " + row.getString("description"));
      Note: The ResultSet is an Iterable object, which can be processed using a for-loop to iterate through each of the rows in the query results.
  6. Run the application.
    Code example