Popular Posts

Tuesday, May 31, 2016

MongoDB tutorial with Java


MongoDB is the most popular No-SQL database. Lets try it out:

1) Install: 
Go to the MongoDb website and download latest release.

2) Run MongoDB:
First command prompt window:
C:\Program Files\MongoDB\Server\3.2\bin>mongod.exe --dbpath D:\mongo\data
Second command prompt window:
C:\Program Files\MongoDB\Server\3.2\bin>mongo.exe

2) Creating a Database: write insert queries
db.mytable.insert({
    first: 'amit',
    last: 'kumar',
    age: 25,
    dob: '21/04/1978',
    gender: 'm',
    occupation: 'developer',
    nationality: 'indian'
});
db.mytable.insert({
    first: 'sumit',
    last: 'singh',
    age: 34,
    dob: '26/03/1940',
    gender: 'm',
    occupation: 'engineer',
    nationality: 'american'
});

3) verify
db.mytable.find()


4) Download Robomongo
connect to database and see the records present there.