Skip to content

Instantly share code, notes, and snippets.

@al3xandru
Created March 26, 2014 03:52
Show Gist options
  • Save al3xandru/9776708 to your computer and use it in GitHub Desktop.
Save al3xandru/9776708 to your computer and use it in GitHub Desktop.
A very basic example of connecting to a Cassandra node using DataStax Java Driver
package com.example.cstar;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
public class MyClient {
public MyClient() {
}
public static void main(String[] args) {
Cluster cluster = Cluster.builder()
.addContactPoints("127.0.0.1")
.build();
Session session = cluster.connect("myschema");
for (Row row : session.execute("SELECT * FROM users")) {
// do something ...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment