Skip to content

Instantly share code, notes, and snippets.

@lankydan
Created April 15, 2018 17:27
Show Gist options
  • Save lankydan/9ac9cbb65ac4d67b6112a5a501b0c69c to your computer and use it in GitHub Desktop.
Save lankydan/9ac9cbb65ac4d67b6112a5a501b0c69c to your computer and use it in GitHub Desktop.
Datastax driver - setup keyspace
private void setupKeyspace(Session session, String keyspace) throws IOException {
final Map<String, Object> replication = new HashMap<>();
replication.put("class", "SimpleStrategy");
replication.put("replication_factor", 1);
session.execute(createKeyspace(keyspace).ifNotExists().with().replication(replication));
session.execute("USE " + keyspace);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment