Running M = newMongo ("localhost", 27017 );
DBdb = m. getDB ("database"); // obtain the database if it exists. Otherwise, it is automatically created.
If (db! = Null) System. out. println ("success ");
ElseSystem. out. println ("fail ");
// Obtain the database's Collectionuser. If the table names of other databases do not exist, create
DBCollectionusers = db. getCollection ("user ");
// Insert data into the database
// The First insert method
DBObjectdata = newBasicDBObject ();
Data. put ("_ id", "1 ");
Data. put ("cust_Id", "123456 ");
Users. put (data );
// Method 2
BasicDBObjectBuilderdata = BasicDBObjectBuilder. start (). add ("_ id", "1"). add (...);
Users. insert (data. get ());
// Method 3
Map <String, Object> map = newHashMap <String, Object> ();
Map. put ("id", 1 );
Users. insert (newBasicDBObject (map ));
// Method 4
Stringjson = "{'id': 1 }";
DBObjctdata = (DBObject) JSON. parse (json );
Users. insert (data );
Not complete to be continued ..