+

MongoDB Java
Using JAVA API to use MongoDB

http://www.youtube.com/zarigatongy
+

Follow Me @
http://youtube.com/zarigatongy

http://www.youtube.com/zarigatongy
+ Using java with MongoDB
 Download
 Make

the Driver from the MongoDB website.

use of the below packages in your class...
+ Using java with MongoDB

Build the following document with
the help of JAVA API
> db.user.findOne()
{
"_id" : ObjectId("...
+ Sample Java Programe
import java.net.UnknownHostException;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
impo...
+ Sample java Programe (Contd…)
/**
* Use BasicDBObject to create document
*/
BasicDBObject userDoc = new BasicDBObject();...
+ Using java with MongoDB

Build the following document with
the help of JAVA API
> db.user.findOne()
{
"_id" : ObjectId("...
+

Sample Java Program 2
/* Create Mongo Instance and get the coolection */

BasicDBObject userDoc = new BasicDBObject();
...
+ Finding Data with query in Collection
public static void main(String[] args) throws UnknownHostException {
/**
* Open up...
+ More Tutorial Available


how to hack websites Sql Injection Attack/prevention By
Example



How java serialization wo...
Upcoming SlideShare
Loading in...5
×

Mongo db java

271

Published on

Published in: Technology, News & Politics
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total Views
271
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
11
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide
  • { "_id" : ObjectId("513f4b2b1257cc7801c09190"), "fName" : "anish01", "lName" : "nath01", "family" : { "fatherName" : "anil", "motherName" : "Indu" }}
  • Mongo db java

    1. 1. + MongoDB Java Using JAVA API to use MongoDB http://www.youtube.com/zarigatongy
    2. 2. + Follow Me @ http://youtube.com/zarigatongy http://www.youtube.com/zarigatongy
    3. 3. + Using java with MongoDB  Download  Make the Driver from the MongoDB website. use of the below packages in your class import com.mongodb.Mongo; import com.mongodb.DB; import com.mongodb.DBCollection; http://www.youtube.com/zarigatongy
    4. 4. + Using java with MongoDB Build the following document with the help of JAVA API > db.user.findOne() { "_id" : ObjectId("513f4b2b1257cc7801c09190"), "fName" : "anish01", "lName" : "nath01", "family" : { "fatherName" : "anil", "motherName" : "Indu" http://www.youtube.com/zarigatongy
    5. 5. + Sample Java Programe import java.net.UnknownHostException; import com.mongodb.BasicDBObject; import com.mongodb.DB; import com.mongodb.DBCollection; import com.mongodb.Mongo; public class TestAddUser { public static void main(String[] args) throws UnknownHostException { /** * Open up the connection in the MongoDB */ Mongo mongo = new Mongo(); /** * use the user DB if not exist http://www.youtube.com/zarigatongy create it
    6. 6. + Sample java Programe (Contd…) /** * Use BasicDBObject to create document */ BasicDBObject userDoc = new BasicDBObject(); userDoc.put("fName", "anish01"); userDoc.put("lName", "nath01"); BasicDBObject familyDetailsDoc = new BasicDBObject(); familyDetailsDoc.put("fatherName", "anil"); familyDetailsDoc.put("motherName", "Indu"); /* Attached to the family doc to the userDocument */ http://www.youtube.com/zarigatongy
    7. 7. + Using java with MongoDB Build the following document with the help of JAVA API > db.user.findOne() { "_id" : ObjectId("513f4eb21257b06b3cf186b6"), "fName" : "anish01", "lName" : "nath01", "family" : { "fatherName" : "anil", "motherName" : "Indu" }, http://www.youtube.com/zarigatongy "remarks" : [
    8. 8. + Sample Java Program 2 /* Create Mongo Instance and get the coolection */ BasicDBObject userDoc = new BasicDBObject(); userDoc.put("fName", "anish01"); userDoc.put("lName", "nath01"); BasicDBObject familyDetailsDoc = new BasicDBObject(); familyDetailsDoc.put("fatherName", "anil"); familyDetailsDoc.put("motherName", "Indu"); /* Attached to the family doc to the userDocument */ userDoc.put("family", familyDetailsDoc); ArrayList<BasicDBObject> remarks = new ArrayList<BasicDBObject>(); remarks.add((BasicDBObject) BasicDBObjectBuilder.start() .add("uName", "arjun").add("feedback", "good").get()); remarks.add((BasicDBObject) BasicDBObjectBuilder.start() http://www.youtube.com/zarigatongy .add("uName", "manisha").add("feedback", "bad").get());
    9. 9. + Finding Data with query in Collection public static void main(String[] args) throws UnknownHostException { /** * Open up the connection in the MongoDB */ Mongo mongo = new Mongo(); /** * use the user DB if not exist create it */ DB db = mongo.getDB("user"); /** * Lookup the user Document in collection */ http://www.youtube.com/zarigatongy DBCollection userCollection = db.getCollection("user");
    10. 10. + More Tutorial Available  how to hack websites Sql Injection Attack/prevention By Example  How java serialization works internally, Object Serialization algorithm  java in programming Solving Producer Consumer Problem  One line java program that throw "java.lang.OutOfMemoryError: Java heap space Analysis Eclipse MAT  thread dump analysis with lab,how to analyse deadlock thread dump with jstack,kill command in java  wireshark tutorial,Top 5 features you must Know in 5 minutes http://www.youtube.com/zarigatongy
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×