-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathArtSchoolRetrieverAll.java
More file actions
37 lines (27 loc) · 1.33 KB
/
ArtSchoolRetrieverAll.java
File metadata and controls
37 lines (27 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import com.couchbase.client.core.error.CouchbaseException;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.json.JsonObject;
import com.couchbase.client.java.query.QueryResult;
import com.couchbase.client.java.ClusterOptions;
public class ArtSchoolRetriever {
public static void main(String[] args) {
String connectionString = "<<connection-string>>"; // Replace this with Connection String
String username = "<<username>>"; // Replace this with username from cluster access credentials
String password = "<<password>>"; // Replace this with password from cluster access credentials
Cluster cluster = Cluster.connect(connectionString, ClusterOptions.clusterOptions(username, password)
.environment(env -> env.applyProfile("wan-development"))
);
retrieveCourses(cluster);
cluster.disconnect();
}
private static void retrieveCourses(Cluster cluster) {
try {
final QueryResult result = cluster.query("select crc.* from `student-bucket`.`art-school-scope`.`course-record-collection` crc");
for (JsonObject row : result.rowsAsObject()) {
System.out.println("Found row: " + row);
}
} catch (CouchbaseException ex) {
ex.printStackTrace();
}
}
}