Connecting to Azure Cosmos Db Cassandra

Answered

Hello!

I'm having problem connecting to Azure Cosmos db cassandra

Has anyone succeeded in connecting to this database?

Java is not my strongest language but by comparing the code in the datagrip jdbc cassandra driver and the azure example

(https://github.com/DataGrip/cassandra-jdbc-driver/blob/68a2a649cf55589e2f17a49b36913aa92c1ebafa/driver/src/main/java/com/dbschema/CassandraClientURI.java

and

https://github.com/Azure-Samples/azure-cosmos-db-cassandra-java-getting-started/blob/master/java-examples/src/main/java/com/azure/cosmosdb/cassandra/util/CassandraUtils.java)

 

The thing that differs is the sslOptions in the azure example is not available for datagrip.

final SSLContext sc = SSLContext.getInstance("TLSv1.2");
sc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new java.security.SecureRandom());

JdkSSLOptions sslOptions = RemoteEndpointAwareJdkSSLOptions.builder()
.withSSLContext(sc)
.build();
cluster = Cluster.builder()
.addContactPoint(cassandraHost)
.withPort(cassandraPort)
.withCredentials(cassandraUsername, cassandraPassword)
.withSSL(sslOptions)
.build();

 But in the datagrip connector we only have:

if (sslEnabled) {
builder.withSSL();

Does anyone know how to solve this issue?

Thank in advance

// Niklas

1 comment
Comment actions Permalink

Hi Niklas,

`if (sslEnabled) builder.withSSL()` was recently added to Cassandra. New driver version is not yet available in DataGrip.

You may try the following:

1. Download new Cassandra driver https://github.com/DataGrip/cassandra-jdbc-driver/releases/tag/v1.3

2. Add it as custom driver https://www.jetbrains.com/help/datagrip/connecting-to-a-database.html#create-a-connection-with-JDBC-driver

3. Create data source using your custom driver

4. Add `sslenabled` option to url on Data Sources and Drivers panel, e.g.: `jdbc:cassandra://localhost:9042/?sslenabled=true`

5. Specify truststore and optional keystore using vm options (see docs here https://docs.datastax.com/en/developer/java-driver/3.0/manual/ssl/#driver-configuration). You can specify vm options in `VM options` field on `Advanced` tab.

I hope it will help!

 

Note that `SSH/SSL` tab is not working for Cassandra. We are now fixing it.

 

0

Please sign in to leave a comment.