Skip to content

Instantly share code, notes, and snippets.

@mpenick
Last active August 23, 2016 20:52
Show Gist options
  • Select an option

  • Save mpenick/932b8ca1b77ff91ca97558f2babb8efa to your computer and use it in GitHub Desktop.

Select an option

Save mpenick/932b8ca1b77ff91ca97558f2babb8efa to your computer and use it in GitHub Desktop.
Examples
#include <cassandra.h>
int main() {
/* Setup and connect to cluster */
CassFuture* connect_future = NULL;
CassCluster* cluster = cass_cluster_new();
CassSession* session = cass_session_new();
/* Add contact points */
cass_cluster_set_contact_points(cluster, "127.0.0.1,...");
/* Provide the cluster object as configuration to connect the session */
connect_future = cass_session_connect(session, cluster);
/* Check for connection failure */
if (cass_future_error_code(connect_future) == CASS_OK) {
/* Do queries */
} else {
/* Handle error */
}
cass_future_free(connect_future);
cass_cluster_free(cluster);
cass_session_free(session);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment