1.Introduction :
- MongoDB is an open source document-oriented NoSQL database system.(From en.wikipedia.org)
- MongoDB is written in C++, with many great features like map-reduce , auto sharding, replication, high availability and etc.(From mkyong.com)
Difference between collection & Table:
The element of data is called documents, stored in collections. One collection may have any number of documents.
==> collections are as tables
==> documents are as records.
2.Installation Of MongoDB:
2.a.Install MongoDB
2.a.Install MongoDB on Windows:
§ How to install MongoDB on Windows.
2)Unzip: (mongodb-win32-1.8.1)
I.SERVER
3) create a data directory for MongoDB:Exple(C:\mymongodb)
=>.\bin\mongod.exe : is the DB server.
4) run this DB Server and specify the data directory by “
dbpath
” è$.\mongodb-win32-1.8.1\bin>mongod --dbpath "c:\mymongodb"
5)Admin the Server by Web Interface : http://your-ipaddress:28017 (Example: http://localhost:28017 )
II.Client :
6)Connect as Client By this command :
$.\bin>mongo
§ Run MongoDB as Windows Service
1. mongod –help
Get to know all the Windows service related commands by typing “mongod –help“.
C:\MongoDB\bin>mongod --help
èThe “–install” and “–remove” commands are what you need.
§ To install as Windows service :
è$#> mongod --dbpath "D:\gl4\formation\5.mongoDB\mymongodb" --logpath "D:\gl4\formation\5.mongoDB\mymongodb\logs.txt" --install --serviceName "MongoDB"
The Cmd Line means :
a.Install “MongoDb” service which point to D:\gl4\formation\5.mongoDB\mymongodb.
b.Logs Outputs is the file : D:\gl4\formation\5.mongoDB\mymongodb\logs.txt
To uninstall :* #> mongod --remove --serviceName "MongoDB"
2.b.Install MongoDB on Ubuntu
See this link
3. MongoDBFactoryHelper FrameWork:
mongoDBHelper is an API based on the pattern "Factory", which helps the developer in getting rid of the awkward handling of mongDB.In effect, we will show you how you exploit it.
=>
3.1. Download Jar File :
Don' forget to start server &client.
- Run Server : $#../bin> mongod --dbpath "D:\gl4\formation\5.mongoDB\mymongodb"
- Run Client : $#./bin> mongo
IF you have Amiguity , follow the installations' Tutos of MongoBD
3.2. Embed the FrameWork in a Eclipse Project :
3.2. Embed the FrameWork in a Eclipse Project :
3.3. Test CRUD Methods : CREATE:
|
3.4. Test CRUD Methods : READ:
|
3.5. Full Example:
|
No comments:
Post a Comment