This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes MongoDB and the fly likes How to insert into MongoDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » MongoDB
Bookmark "How to insert into MongoDB" Watch "How to insert into MongoDB" New topic
Author

How to insert into MongoDB

malik ge
Ranch Hand

Joined: May 13, 2011
Posts: 69
Hi,
I don't know if this the right forum for asking this type of question.

In mysql I use to do:

Can anyone tell me how can I do that in mongodb?
I am getting the firstName and lastName from HTML form,
by "request.getParameter" and want to pass these values through Servlet to mongodb.

Thanks

Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

I would first try a tutorial mongodb tutorial java
malik ge
Ranch Hand

Joined: May 13, 2011
Posts: 69
Wendy Gibbons, I have a little knowledge about this:


but most of the tutorials I have found does the above.
What I wanna know if some new user with
name "James",
surname"Bond",
age 23
enters his information in the html form,
then how can I pass that to mongodb.

Means, how can I pass this information through "doc" object
doc.put("name" , ???);
doc.put("surname" , ???);
doc.put("age" , ???);
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

which part is confusing you? how to get the details from the web form to the servlet or how to get the details from the servlet into the mongo database?
malik ge
Ranch Hand

Joined: May 13, 2011
Posts: 69
how to get the details from the servlet into the mongo database?


I know by using Stirng name = request.getParameter("name"), I can get the name of the user.
but don't know how to insert that name, in the following code:
doc.put("name" , ???);
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

malik ge wrote:
how to get the details from the servlet into the mongo database?


I know by using Stirng name = request.getParameter("name"), I can get the name of the user.
but don't know how to insert that name, in the following code:
doc.put("name" , ???);


in your code have you tried
doc.put("name", name)?
malik ge
Ranch Hand

Joined: May 13, 2011
Posts: 69


Thanks a lot.
 
 
subject: How to insert into MongoDB
 
Similar Threads
Check for Duplicates
JDBC Connection successful but havin problems with the SQL Statements in java now :(
Escape Character Help
MongoDB and NoSQL - when to use or not use it?
PreparedStatement with dynamic variable?