Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CONNECT
- // - setup cluster
- CassCluster* cluster = cass_cluster_new();
- // - add contact points
- cass_cluster_set_contact_points(cluster, "127.0.0.1");
- // - connect to cluster
- CassSession* session = cass_session_new();
- // - provide the cluster object as configuration to connect the session
- CassFuture* connect_future = cass_session_connect(session, cluster);
- // - this operation will block until the result is ready
- CassError rc = cass_future_error_code(connect_future);
- if (rc != CASS_OK) {
- CassPrintError(connect_future);
- cass_future_free(connect_future);
- return false;
- }// if error ...
- cass_future_free(connect_future);
- // CREATE KEYSPACE
- if (CassExecuteQuery(session, "CREATE KEYSPACE IF NOT EXISTS chaos WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}") != CASS_OK) {
- // error has been printed within CassExecuteQuery
- return false;
- }// if error ...
- // USE
- if (CassExecuteQuery(session, "USE chaos") != CASS_OK) {
- // error has been printed within CassExecuteQuery
- return false;
- }// if error ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement