MCPcopy Create free account
hub / github.com/MariaDB/server / MongoConnect

Method MongoConnect

storage/connect/Mongo2Interface.java:66–104  ·  view source on GitHub ↗
(String[] parms)

Source from the content-addressed store, hash-verified

64 } // end of GetErrmsg
65
66 public int MongoConnect(String[] parms) {
67 int rc = 0;
68
69 if (DEBUG)
70 System.out.println("Mongo2: URI=" + parms[0] + " DB=" + parms[1]);
71
72 try {
73 MongoClientURI uri = new MongoClientURI(parms[0]);
74
75 client = new MongoClient(uri);
76
77 if (DEBUG)
78 System.out.println("Connection " + client.toString() + " established");
79
80 // Now connect to your databases
81 db = client.getDB(parms[1]);
82
83 if (parms[2] != null && !parms[2].isEmpty()) {
84 if (DEBUG)
85 System.out.println("user=" + parms[2] + " pwd=" + parms[3]);
86
87 @SuppressWarnings("deprecation")
88 boolean auth = db.authenticate(parms[2], parms[3].toCharArray());
89
90 if (DEBUG)
91 System.out.println("Authentication: " + auth);
92
93 } // endif user
94
95 } catch (MongoException me) {
96 SetErrmsg(me);
97 rc = -1;
98 } catch (Exception e) {
99 SetErrmsg(e);
100 rc = -3;
101 } // end try/catch
102
103 return rc;
104 } // end of MongoConnect
105
106 public int MongoDisconnect() {
107 int rc = 0;

Callers 4

mainMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45

Calls 1

SetErrmsgMethod · 0.95

Tested by 2

mainMethod · 0.36
mainMethod · 0.36