Java MongoDB Tutorial

mongodb-tutorials

MongoDB, noSQL open source database, written in C++, with many great features like map-reduce , auto sharding, replication, high availability and etc.

The following Java / Spring Data MongoDB tutorials and examples are tested with :

  1. MongoDB 2.2.3
  2. Java-MongoDB-Driver 2.11.0
  3. Spring-Data-MongoDB 1.2.0.RELEASE

1. MongoDB Core Examples

MongoDB installation, configuration, connect, query and backup.

2. Java MongoDB Examples

Java MongoDB driver APIs examples to perform insert, update, query and delete documents from MongoDB.

3. Spring Data MongoDB Examples

Spring Data for MongoDB examples to perform insert, update, query and delete documents from MongoDB.

4. MongoDB FAQs

Some common questions and answers in MongoDB.

References

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

Leave a Reply

avatar
newest oldest most voted
Dhyanandra Singh
Guest
Dhyanandra Singh

hello Mkyong, currently i am using Embedded document design in mongodb. and i want to use it with spring data how can i do that

Me
Guest
Me

It was very helpful!
Thanks!! :)

Carol
Guest
Carol

Thanks for this complete tutorial

Snehal
Guest
Snehal

I am working on java application using mongo, I want to check if there is any other option to remove documents from collection after some time period… I checked createIndex option for implementing TTL .. but it needs timestamp column to be present in collection, is there any other way to implement TTL with timestamp column and createIndex option ?

Irfan
Guest
Irfan

Hello Mkyong!
I want to build a search panel, in which I will put name and it will show me all data from database related to that name.
I want to create that in java with database Mongodb

Rathinavel
Guest
Rathinavel
Hello Mkyong, Is there any way to use multi update in same array object using java. { “_id” : ObjectId(“58859d758c0f1c0c385a2f42”), “medications” : [ { “id” : 23.0, “name” : “A”, “type” : “B” }, { “id” : 41.0, “name” : “C”, “type” : “D” }, { “id” : 41.0, “name” : “C”, “type” : “D” } ] } db.tutorial.update({ “medications.id”: 41.0 },{“$set”:{“medications.$.name”:”Test”}},{“multi”:true}) above query is updating only one element in array please help me soon.
Sameer Bhatia
Guest
Sameer Bhatia

Can you please share an example with MondoDB and Hibernate ?

rew
Guest
rew
I have this query in JS arrStrudent = db.students.aggregate([{$project:{scores: {$filter: {input: “$scores”,as: “item”,cond: { $eq: [“$$item.type”, “homework”]}}}}},{“$unwind”: “$scores”},{ $sort : { _id : 1, scores: 1 } },{$project : { “scores.score” :1} }]);null; var tmpId = -1; while (arrStrudent.hasNext()) {v = arrStrudent.next();if (v._id != tmpId) {print(v._id + “==>” + v.scores.score);tmpId = v._id;db.students.update({ _id : v._id},{ $pull: { scores: { score : v.scores.score }}})}} arrStrudent.close(); this is to remove lowest score within the scores array of student collections. =============== Now I want do same in Java, can you help me with aggregate query ? I worte something like this, and this… Read more »
hari
Guest
hari

Hello please help me to learn java play framework from scratch

Alex
Guest
Alex

“Auto Sequence ID Example” links to “Hello World example” and vice versa..

tank
Guest
tank

Spring Data MongoDB hello world example wrong link

mrugesh
Guest
mrugesh

hello, right now i am doing research on mongodb’s auto sharding
proces..i can run simple connection of mongodb through java code..but i
cant find java code for sharding process..so can u please send me that code..

thanks for adavance..

Om Prakash Shakya
Guest
Om Prakash Shakya

Excellent stuffs regarding mongodb. Try mongodb commands online http://www.domongodb.com

trackback
MongoDB modelo de dados orientado a documentos NoSQL: Introdução | brunotutorials

[…] Java e MongoDB na página do Mkyong: http://www.mkyong.com/tutorials/java-mongodb-tutorials/ […]

Android Guru
Guest
Android Guru

You can start learning Android programming from scratch through this blog – http://android.programmerguru.com.
Blog is targetted for Freshers or novice programmers who want to begin learning Android application development.

nirmal
Guest
nirmal
trackback
Windowsta Java + MongoDB | madvens

[…] olarak faydal? bir link : http://www.mkyong.com/tutorials/java-mongodb-tutorials/ Payla??n:Like this:Be?enBe the first to like this post. This entry was posted in kodmod and […]

trackback
Early MongoDB peep