-
Notifications
You must be signed in to change notification settings - Fork 1
/
DB_Init.java
47 lines (38 loc) · 1.29 KB
/
DB_Init.java
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
38
39
40
41
42
43
44
45
46
47
import org.bson.Document;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
public class DB_Init {
/*MongoClient mongo;
MongoDatabase db;
MongoCollection<Document> original_table, filtered_collection;
public DB_Init() {
System.out.println("In db init");
mongo = new MongoClient();
System.out.println("After connection");
db = mongo.getDatabase("testdb");
//db = mongo.getDB("testdb");
original_table = db.getCollection("students");
filtered_collection = db.getCollection("filtered");
System.out.println("exiting db init");
}*/
Cluster cluster;
Session session;
String command;
MongoClient mongo;
MongoDatabase db;
MongoCollection<Document> original_table, filtered_collection;
public DB_Init() {
System.out.println("In db init");
mongo = new MongoClient();
cluster = Cluster.builder().addContactPoint("127.0.0.1").build();
session = cluster.connect("test");
db = mongo.getDatabase("testdb");
//db = mongo.getDB("testdb");
original_table = db.getCollection("students");
filtered_collection = db.getCollection("filtered");
System.out.println("exiting db init");
}
}