How to connect to Cassandra Cloud AstraDb with JDBC ?

Data Modeling Chebotko Logical

About

This article shows you how you can connect to an AstraDb database with Jdbc. 1)

Steps

Download the Cassandra Astra Driver

Download the JDBC driver at datastax 2)

Download Jdbc Cassandra

Optional for Idea - Create a new driver

Create a new driver with the following properties:

  • Driver File: CassandraJDBC42.jar
  • Driver Class: com.simba.cassandra.jdbc42.Driver

Idea Datagrip Astradb Drivers

Auth

From the Astra DB console:

Connect String

Create a new connection with the following JDBC URL

jdbc:cassandra://keyspace;DefaultKeyspace=keyspace;AuthMech=2;UID=token;PWD=<ApplicationToken>;SecureConnectionBundlePath=<PATH TO YOUR SECURE CONNECT BUNDLE>;TunableConsistency=6

where:

  • keyspace is the keyspace you want to connect to (Optional)
  • DefaultKeyspace is the default keyspace (Optional)
  • AuthMech: Specifies whether the driver connects to a Cassandra or Astra DB database and whether the driver authenticates the connection.
  • ApplicationToken: The generated from Astra DB console.
  • SecureConnectionBundlePath: Path to where your downloaded Secure Connect Bundle is located.
  • TunableConsistency: Specifies Cassandra replica or the number of Cassandra replicas that must process a query for the query to be considered successful.

Example on Idea:

Astradb Idea Jdbc Connection

For legacy driver, client id and client secret correspond to username and password. They are created when you generate your application token.





Discover More
Data Modeling Chebotko Logical
Cassandra - Client

This article lists the client that can connect to Cassandra. Cassandra Database Tool ...



Share this page:
Follow us:
Task Runner