Skip to content

Commit b0da08b

Browse files
author
a-brandt
committed
deleted an import
1 parent 6ffe77d commit b0da08b

File tree

1 file changed

+65
-62
lines changed

1 file changed

+65
-62
lines changed

src/test/java/com/arangodb/example/ExampleMDB.java

Lines changed: 65 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -21,76 +21,79 @@
2121
import com.arangodb.ArangoConfigure;
2222
import com.arangodb.ArangoDriver;
2323
import com.arangodb.ArangoException;
24-
import com.arangodb.entity.CollectionType;
2524
import com.arangodb.entity.DocumentEntity;
2625
import com.arangodb.util.MapBuilder;
2726

2827
/**
29-
* Switch many database.
28+
* Switch many database.
29+
*
3030
* @author tamtam180 - kirscheless at gmail.com
3131
* @since 1.4.0
3232
*/
3333
public class ExampleMDB {
3434

35-
public static void main(String[] args) {
36-
37-
// Initialize configure
38-
ArangoConfigure configure = new ArangoConfigure();
39-
configure.init();
40-
41-
// Create Driver (this instance is thread-safe)
42-
// If you use a multi database, you need create each instance.
43-
ArangoDriver driverA = new ArangoDriver(configure); // db = _system (configure#defaultDatabase)
44-
ArangoDriver driverB = new ArangoDriver(configure, "mydb2");
45-
46-
try {
47-
48-
try {
49-
driverA.deleteCollection("example1");
50-
} catch (Exception e) {}
51-
try {
52-
driverB.deleteDatabase("mydb2");
53-
} catch (Exception e) {}
54-
try {
55-
driverB.deleteCollection("example2");
56-
} catch (Exception e) {}
57-
58-
// Create Collection at db(_system)
59-
driverA.createCollection("example1");
60-
driverA.createDocument("example1",
61-
new MapBuilder().put("attr1", "value1").put("attr2", "value2").get(),
62-
false, false);
63-
64-
// Create Database mydb2
65-
driverB.createDatabase("mydb2");
66-
67-
// Create Collection at db(mydb2)
68-
driverB.createCollection("example2");
69-
driverB.createDocument("example2",
70-
new MapBuilder().put("attr1-B", "value1").put("attr2-B", "value2").get(),
71-
false, false);
72-
73-
// print all database names.
74-
System.out.println(driverA.getDatabases());
75-
// -> _system, mydb2
76-
77-
// get all document-handle, and print get & print document. (_system DB)
78-
for (String documentHandle: driverA.getDocuments("example1", true)) {
79-
DocumentEntity<Map<String, Object>> doc = driverA.getDocument(documentHandle, Map.class);
80-
System.out.println(doc.getEntity());
81-
}
82-
83-
for (String documentHandle: driverB.getDocuments("example2", true)) {
84-
DocumentEntity<Map<String, Object>> doc = driverB.getDocument(documentHandle, Map.class);
85-
System.out.println(doc.getEntity());
86-
}
87-
88-
} catch (ArangoException e) {
89-
e.printStackTrace();
90-
} finally {
91-
configure.shutdown();
92-
}
93-
94-
}
35+
public static void main(String[] args) {
36+
37+
// Initialize configure
38+
ArangoConfigure configure = new ArangoConfigure();
39+
configure.init();
40+
41+
// Create Driver (this instance is thread-safe)
42+
// If you use a multi database, you need create each instance.
43+
ArangoDriver driverA = new ArangoDriver(configure); // db = _system
44+
// (configure#defaultDatabase)
45+
ArangoDriver driverB = new ArangoDriver(configure, "mydb2");
46+
47+
try {
48+
49+
try {
50+
driverA.deleteCollection("example1");
51+
} catch (Exception e) {
52+
}
53+
try {
54+
driverB.deleteDatabase("mydb2");
55+
} catch (Exception e) {
56+
}
57+
try {
58+
driverB.deleteCollection("example2");
59+
} catch (Exception e) {
60+
}
61+
62+
// Create Collection at db(_system)
63+
driverA.createCollection("example1");
64+
driverA.createDocument("example1", new MapBuilder().put("attr1", "value1").put("attr2", "value2").get(),
65+
false, false);
66+
67+
// Create Database mydb2
68+
driverB.createDatabase("mydb2");
69+
70+
// Create Collection at db(mydb2)
71+
driverB.createCollection("example2");
72+
driverB.createDocument("example2",
73+
new MapBuilder().put("attr1-B", "value1").put("attr2-B", "value2").get(), false, false);
74+
75+
// print all database names.
76+
System.out.println(driverA.getDatabases());
77+
// -> _system, mydb2
78+
79+
// get all document-handle, and print get & print document. (_system
80+
// DB)
81+
for (String documentHandle : driverA.getDocuments("example1", true)) {
82+
DocumentEntity<Map<String, Object>> doc = driverA.getDocument(documentHandle, Map.class);
83+
System.out.println(doc.getEntity());
84+
}
85+
86+
for (String documentHandle : driverB.getDocuments("example2", true)) {
87+
DocumentEntity<Map<String, Object>> doc = driverB.getDocument(documentHandle, Map.class);
88+
System.out.println(doc.getEntity());
89+
}
90+
91+
} catch (ArangoException e) {
92+
e.printStackTrace();
93+
} finally {
94+
configure.shutdown();
95+
}
96+
97+
}
9598

9699
}

0 commit comments

Comments
 (0)