how do i search for an entry in mongodb database using java in netbeans?

nupur kamble

I have made a database in Mongodb and a collection with a few entries.I want to search for an entry using Java and also display it. I'm using Netbeans as my IDE. I tried searching all over the internet but couldn't find anything relevant. I'm new to Java and Mongodb.

conFusl
 DBObject result = new Mongo().getDb("yourDatabaseName").getCollection("yourTableName").findOne(new BasicDBObject("id", id), new BasicDBObject("specialColumn", 1));
return result.get("specialColumn")

This example will search for the field "specialColumn" in the collection "yourTableName" with the id "id"! There are more methods provided like .find(), where you can process with a DBCursor to check the results!

http://docs.mongodb.org/manual/tutorial/query-documents/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do i store data into a MongoDb Database using Java?

How do I delete a database entry using Axios?

Using these methods, how do I check if this entry is in a SQL database?

In SQLite, how do I search my database with text from an entry box, and display the result as text?

Using golang and mgo, how do I search for a range of values in MongoDB?

How do I create a new database in MongoDB using PyMongo?

How do I drop a MongoDB database using PyMongo?

How do I drop a database or collection using Hibernate OGM with MongoDB

How can I do a table in Java (Netbeans)?

How do I query a Data from a MySQL database using Tkinter Entry

How do I delete from a SQLite database in python using a tkinter entry instead of stating a string or value?

Using a Data Table, how do I check if the data matches an entry in an Access database and adds the content?

MongoDB: How do I search multiple collections within same database and return mixed result set?

How can I do search method using hashtable in java?

How do I search for a data, using Java HTTP?

I can't store data localhost(database) using java netbeans

How do I execute a MongoDB js script using the Java MongoDriver

How do I optimize my MongoDB Database?

How do I ask if the user would like to continue the game after each dice roll in java using netbeans

How do I avoid duplicate object entry in Mongodb?

How do I run a scraper on each entry in a database?

How do I update an existing entry in my database?

How do I query the database using Mongodb after I set up a Mongoose schema for authentication?

How do I filter data from database arrays using Search bar

How do I search for a particular item in my database using Swift and Firebase?

How do I search for an attribute using BeautifulSoup?

How do I get input from System.in (Java) in Netbeans?

How do I create a distributable Java template for Netbeans 7.1?

How do I write to the Netbeans Debugger Console (in Java)?