Created
March 26, 2014 03:52
-
-
Save al3xandru/9776708 to your computer and use it in GitHub Desktop.
A very basic example of connecting to a Cassandra node using DataStax Java Driver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.cstar; | |
| import com.datastax.driver.core.Cluster; | |
| import com.datastax.driver.core.Row; | |
| import com.datastax.driver.core.Session; | |
| public class MyClient { | |
| public MyClient() { | |
| } | |
| public static void main(String[] args) { | |
| Cluster cluster = Cluster.builder() | |
| .addContactPoints("127.0.0.1") | |
| .build(); | |
| Session session = cluster.connect("myschema"); | |
| for (Row row : session.execute("SELECT * FROM users")) { | |
| // do something ... | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment