import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Metadata;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
* A simple client application that illustrates connecting to
* a Cassandra cluster. retrieving metadata, creating a schema,
* loading data into it, and then querying it.
*/
public class{
private Session session;
public (){
}
* Connects to the specified node.
* @param node a host name or IP address of the node in the cluster
*/
public void connect(String node){
Cluster cluster = Cluster.builder()
.addContactPoint(node)
// .withCredentials("xiaoxiaomo", "blog")
.build();
Metadata metadata = cluster.getMetadata();
System.out.printf("Connected to cluster: %sn",
metadata.getClusterName());
session = cluster.connect();
}
public void connect(String[] nodes,int port){
Cluster cluster = Cluster.builder()
.addContactPoints(nodes)
.withPort(port)
.withCredentials("xiaoxiaomo", "blog")
.build();
Metadata metadata = cluster.getMetadata();
System.out.printf("Connected to cluster: %sn",
metadata.getClusterName());
session = cluster.connect();
}
* Creates the simplex keyspace and two tables, songs and playlists.
*/
public void createSchema(){
session.execute(
"CREATE KEYSPACE IF NOT EXISTS simplex WITH replication " +