Cassandra – Referenced Api

This chapter covers all the important classes in Cassandra.

Cluster

This class is the main entry point of the driver. It belongs to com.datastax.driver.core package.

Methods

S. No.Methods and Description
1Session connect()It creates a new session on the current cluster and initializes it.
2void close()It is used to close the cluster instance.
3static Cluster.Builder builder()It is used to create a new Cluster.Builder instance.

Cluster.Builder

This class is used to instantiate the Cluster.Builder class.

Methods

S. NoMethods and Description
1Cluster.Builder addContactPoint(String address)This method adds a contact point to cluster.
2Cluster build()This method builds the cluster with the given contact points.

Session

This interface holds the connections to Cassandra cluster. Using this interface, you can execute CQL queries. It belongs to com.datastax.driver.core package.

Methods

S. No.Methods and Description
1void close()This method is used to close the current session instance.
2ResultSet execute(Statement statement)This method is used to execute a query. It requires a statement object.
3ResultSet execute(String query)This method is used to execute a query. It requires a query in the form of a String object.
4PreparedStatement prepare(RegularStatement statement)This method prepares the provided query. The query is to be provided in the form of a Statement.
5PreparedStatement prepare(String query)This method prepares the provided query. The query is to be provided in the form of a String.

Leave a Reply