2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

how to connect with cassandra using java

how to connect with cassandra using java
userimage

1st we need to import cassandra java driver:

<dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>cassandra-driver-core</artifactId>
       <version>2.1.9</version>
</dependency>

else download jar from here : CASSANDRA DRIVER

2nd : java code to connect with cassandra db:


import com.datastax.driver.core.Cluster;

public class DBConnection {

    public static Cluster CLUSTER;

    static {
        CLUSTER = Cluster.builder().addContactPoints("Provide Host Name/ IP").build();
    }
}

and from CLUSTER you can get a session and do the CRUD operation.

Answer is