First time writing technology! Plain English talk about it. Just take it with you.
I am, net of technical staff, will point Java so a lot of unprofessional, forgive Ha
I just started using MONGO for two days before I got a half-bucket of water.
Casually put MONGO in Win's build also write down. Actually, this is nothing to write about. Very simple
I'm using the latest version of MONGO.
Installed directory is C-drive
Then the database is placed underneath the other disks.
Create a new directory based on the following command. MongoDB.log, this is not a new one.
Create a new MONGO service. This will allow you to use the boot.
[Plain]View PlainCopy
- Mongod--dbpath O:\mongodb\data\db--logpath O:\mongodb\data\log\MongoDB.log--install--servicename Mongodbmet
In this case, you will be presented with our new server. A little do not know how, my service name is not actually written by myself, has been MongoDB
Now the library is basically built up. Especially want to build a cluster. But I don't know how to build it. Still in the study.
The use of management tools is a headache, I found two online, as if not support the latest MONGO library, do not know whether the cause of the configuration or what
It's best not to use the Charge management tool "NoSQL Manager for MongoDB" This is very powerful, easy to use, compatible with the latest library
Start Java link Now there's a hole in this place, and maybe it's a hole for me. is to use Mongodb-driver-3.4.2.jar This package must be used in conjunction with the other two packages. Mongodb-driver-core-3.4.2.jar and Bson-3.4.2.jar, respectively, were just beginning to know, and the first one was quoted. No errors were written. operation on the error. Link is not on MongoDB, at that time saw a lot of dishes to understand, there is this three package must be the same version, or it is an error. I'm using the latest 3.4.2. It's all up to date. Now use normal
Post Code now
[Java]View PlainCopy
Mongoclient mongoclient = null;
Mongodatabase database = null;
mongocollection<document> collection = null;
Public Metstrfy () {
String mongohost = Setsystemproperty.readvalue ("Mongohost"); Address
String MONGODK = Setsystemproperty.readvalue ("MONGODK"); Port
String mongofydb = Setsystemproperty.readvalue ("Mongofydb"); Database name
String mongofydata = Setsystemproperty.readvalue ("Mongofydata"); Table name
Mongoclient = New Mongoclient (Mongohost, Integer.parseint (MONGODK));
Database = Mongoclient.getdatabase (MONGOFYDB);
Collection = Database.getcollection (Mongofydata);
}
Send ID query information out. The return is in JSON format OH. Change it yourself,
[Java]View PlainCopy
- Public string Getmodel (String Pmid) {
-
- Metfymodel model = new Metfymodel ();
- Document MyDoc = Collection.find (new Basicdbobject ("id", ID)). First ();
- Mongoclient.close ();
- return Mydoc.tojson ();
- //return model;
-
- }
All right. The rest of the road is still a lot. I have to study it slowly.
Use of the package sent to everyone, you can try the hair ha
Https://oss.sonatype.org/content/repositories/releases/org/mongodb/mongodb-driver-core/3.4.2/mongodb-driver-core-3.4.2.jar
Https://oss.sonatype.org/content/repositories/releases/org/mongodb/bson/3.4.2/
Https://oss.sonatype.org/content/repositories/releases/org/mongodb/mongodb-driver/3.4.2/
MongoDB Project Integration Mongo-driver 3.4.2