
Welcome, we will discover in this tutorial how to connecting Spark with Cassandra database using the Java language. The code will be done in Java you will find it the Gist Github links in the tutorial.
Video Demo
Installing DataStax Distribution of Apache Cassandra
Adding dependencies Cassandra
To use Cassandra with Apache Spark we need Cassandra Connector for Spark.
First we’ll create a new Maven project with Eclipse, for this example I will create a small product management application. I choose tn.esprit
as Group Id and cassandra
as Artifact Id.
Create CassConnector(java class) that will connect to the cassandra database, and we’re going to create a new KEYSPACE and use it.
Execution & test with Cassandra CQL shell
To run our application, we must first generate it with Manven by running maven install
and right click on the CassConnector.java file and Run As Java Application .
Now test the creation of new KEYSPACE with Cassandra CQL shell