Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started



ortizfabio_185816 avatar image
ortizfabio_185816 asked Erick Ramirez answered

How do I migrate from spark-cassandra-connector 2.0 to 3.0?

Can anybody tell me what changes I need to made to the code below running on 2.0.8 spark connector vs 3.0.0 which uses java-driver-core 4.0.0

I am getting an error on code that was calling com.datastax.driver.core.Cluster
There is seem to be gone. This code does not work:

                Cluster cluster = Cluster.builder().addContactPoints(hosts.split(","))
                        .withCredentials(user, password)
spark-cassandra-connectorjava driver
1 comment
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

I found the instructions here:

which simple instructions:

CqlSessionBuilder builder = CqlSession.builder()
        .addContactPoint(new InetSocketAddress("", 9042))
        .addContactPoint(new InetSocketAddress("", 9042))
        .withSslContext(new SSLContext())
        .withCredentials(user, password)

However the SSL is not as easy as before. The instructions are here

However they don't look at simple. Before I needed to specify connect on the session. Now it appears that build connects automatically.

0 Likes 0 ·

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

The Spark Cassandra connector 3.0.0 uses Java driver v4.7 (whereas v2.0 of the connector used Java driver v3.0).

The Java driver was redesigned in version 4 so it is not binary-compatible with older versions. You will need to rewrite your application to use the new API.

You are correct that Cluster does not exist anymore and was replaced with CqlSession. See the Java driver v4.7 Upgrade Guide for details.

Also, you referenced v4.3 of the docs. For completeness, here is the Java driver v4.7 SSL page. Cheers!

10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.