Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. // CONNECT
  2. // - setup cluster
  3. CassCluster* cluster = cass_cluster_new();
  4. // - add contact points
  5. cass_cluster_set_contact_points(cluster, "127.0.0.1");
  6. // - connect to cluster
  7. CassSession* session = cass_session_new();
  8. // - provide the cluster object as configuration to connect the session
  9. CassFuture* connect_future = cass_session_connect(session, cluster);
  10. // - this operation will block until the result is ready
  11. CassError rc = cass_future_error_code(connect_future);
  12. if (rc != CASS_OK) {
  13. CassPrintError(connect_future);
  14. cass_future_free(connect_future);
  15. return false;
  16. }// if error ...
  17. cass_future_free(connect_future);
  18.  
  19. // CREATE KEYSPACE
  20. if (CassExecuteQuery(session, "CREATE KEYSPACE IF NOT EXISTS chaos WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}") != CASS_OK) {
  21. // error has been printed within CassExecuteQuery
  22. return false;
  23. }// if error ...
  24.  
  25. // USE
  26. if (CassExecuteQuery(session, "USE chaos") != CASS_OK) {
  27. // error has been printed within CassExecuteQuery
  28. return false;
  29. }// if error ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement