Connection class

Let's start by building a class to handle the connection to Apache Cassandra. We'll try to make this robust enough to be useful for each exercise to follow. First of all, let's specify our package (if it's not already specified), and import a few classes from the driver:

package PacktCassDev;import com.datastax.driver.core.Cluster;import com.datastax.driver.core.ConsistencyLevel;import com.datastax.driver.core.Session;import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;import com.datastax.driver.core.policies.TokenAwarePolicy;import com.datastax.driver.core.ResultSet;import com.datastax.driver.core.BoundStatement;import com.datastax.driver.core.QueryOptions;
The name of your package may differ from the example ...

Get Mastering Apache Cassandra 3.x - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.