DataStax Astra Developer Hub

Welcome to the DataStax Astra Developer Hub. You'll find comprehensive guides and documentation to help you start working with DataStax Astra as quickly as possible. Use the included APIs to create, modify, and terminate databases, and interact with the databases you create. Let's do it!

Get Started    API Reference

Migrating your DataStax Java driver to connect with Astra databases

Complete the following procedure to migrate your existing DataStax Java driver to a version capable of connecting to Astra databases created using DataStax Astra.

Prerequisites

  1. Create a database using DataStax Astra.
  2. Download the secure connect bundle to obtain connection credentials for your DataStax Astra database.

📘

Tip

Alternatively, have a teammate provide access to their Astra database.

Procedure

  1. In your existing DSE Java driver code, update dependencies to include the DSE Java driver version that can connect to Astra databases.
<dependency>
  <groupId>com.datastax.oss</groupId>
  <artifactId>java-driver-core</artifactId>
  <version>4.6.0</version>
</dependency>
<dependency>
  <groupId>com.datastax.cassandra</groupId>
  <artifactId>cassandra-driver-core</artifactId>
  <version>3.8.0</version>
</dependency>
<dependency>
  <groupId>com.datastax.dse</groupId>
  <artifactId>dse-java-driver-core</artifactId>
  <version>2.3.0</version>
</dependency>
<dependency>
  <groupId>com.datastax.dse</groupId>
  <artifactId>dse-java-driver-core</artifactId>
  <version>1.9.0</version>
</dependency>
  1. Optional: To use DSE QueryBuilder, which is a utility used to generate CQL queries programmatically, add the following dependency to your pom.xml file:
<groupId>com.datastax.dse</groupId>
  <artifactId>dse-java-driver-query-builder</artifactId>
  <version>4.6.0</version>
</dependency>
  1. Modify the connection code to use the DataStax Astra API.
    In the CqlSession or Session objects (DseCluster or DseSession objects for DSE), include the path to the secure connect bundle for your Cassandra database (secure-connect-**database_name**.zip) in the withCloudSecureConnectBundle() method, as shown in the following example.
CqlSession session = CqlSession.builder()
  .withCloudSecureConnectBundle("/path/to/secure-connect-database_name.zip")
  .withAuthCredentials("username","password")
  .withKeyspace("keyspace_name")
  .build())
Session session = Cluster.builder()
  .withCloudSecureConnectBundle("/path/to/secure-connect-database_name.zip")
  .withAuthProvider(new PlainTextAuthProvider("username", "password"))
  .build()
  .connect("keyspace_name"))
DseSession session = DseSession.builder()
  .withCloudSecureConnectBundle("/path/to/secure-connect-database_name.zip")
  .withAuthCredentials("username", "password")
  .withKeyspace("keyspace_name")
  .build();
DseCluster cluster = DseCluster.builder()
  .withCloudSecureConnectBundle("/path/to/secure-connect-database_name.zip")
  .withCredentials("username", "password")
  .build();
DseSession session = cluster.connect("keyspace_name");

📘

Note

If converting from using the open source Cassandra Java driver to the DSE Java driver, ensure that you change Session to DseSession.

  1. Build the project to test the connection.
    mvn clean compile exec:java -Dexec.mainClass=YourJavaDriver.java
    If successful, the code builds, compiles, and connects to your Cassandra database.

Updated 20 days ago


Migrating your DataStax Java driver to connect with Astra databases


Complete the following procedure to migrate your existing DataStax Java driver to a version capable of connecting to Astra databases created using DataStax Astra.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.