我和Cassandra工作了很多,感觉我多年来已经从数据库中拿出了足够的BS.只是想知道为什么这不适用于数据存储java驱动程序的Apache Cassandra 2.1.0(或2.0.8)w/2.1.1.看起来这应该是有用的.
public class BS {
public static void main(String [] args) {
Cluster cluster = Cluster.builder().addContactPoint("192.168.1.6").build();
Metadata metadata = cluster.getMetadata();
System.out.printf("Connected to cluster: %s\n", metadata.getClusterName());
Session session = cluster.connect();
session.execute("CREATE KEYSPACE IF NOT EXISTS fook WITH replication= {'class':'SimpleStrategy', 'replication_factor':1 }");
session.execute("CREATE TABLE IF NOT EXISTS fook.dooftbl (id bigint PRIMARY KEY, doof text, ownerid bigint)");
long id = new Random().nextLong();
long ownerid = new Random().nextLong();
String doof = "broken db";
String load = "INSERT INTO fook.dooftbl (id,doof,ownerid) VALUES (?,?,?)"; …Run Code Online (Sandbox Code Playgroud)