MongoDB is a scalable, high-performance, open source, document-oriented database. This tag is used for questions related to the Java language bindings and drivers for MongoDB.
I am reading MongoDB results using the following code , however the while loop runs in an infinite loop always iterating over the first element in the collection, can someone point out what I am doing wrong.
Iterable list =…
I have two class called School and Student as you see. I want to search for "students that school names are bla bla bla" and "schools that have students which has higher grade than 90". I read some documents but I am a little confused.
public class…
I am trying to connect to remote MongoDB (mongolab) from my local GAE server (localhost/8888). I am using morphia and my mongodb driver version is 2.4. My code looks like this:
Mongo m = new Mongo("xyz.mongolab.com",);
Datastore datastore = new…
I want to convert a CSV line into a GeoJSON object. I am using CSVReader. Hence, nextLine[] has all the separated tokens.
I want to create BasicDBObject which has various attributes stored. I am doing it following way.
new…
I'm about to build a project in Play Framework for Java 2.1 and I would like to use MongoDB to store data. I've installed both Play 2.1 and MongoDB 2.4.4.
Is it possible to build a Play! project with only the MongoDB Java Driver? I've actually…
I am new to mongodb, I have a JSON like this:
{
"first_name" : "John",
"last_name" : "Smith",
"address" : {
"street" : "123 Main Street",
"city" : "Anytown",
"state" : "NY"
}
}
Now I want to find all…
I am using java async driver for mongoDb not the default driver
I have a db 'test' with collection 'collect' with each document in the form given below where time is the 10 digit unix timestamp
{ "_id", "userId", "programId", "time" }
I wanted to…
This may be a bit more complicated than it needs to be, but I am using:
mongoDB
Spark
Freemarker
java
I cannot figure out how to access embedded data in mongodb to print on the website. I want to be able to look through the records, find which…
I've written a simple Java server. The basic idea is that, upon clicking a button, a servlet will load some data into MongoDB.
However, whenever I try to actually load something into MongoDB (in my case, saving a collection), I get the following…
I'm now using Netty as my backend webservice and MongoDB as my database.
At first, I'm very glad with the high performance of the combination of MongoDB and Netty.
But recently I checked the MongoDB logs(and db.serverStatus() command) and found a…
I need to keep some binary data in my MongoDB collection. It seems that I'm getting different JSON representation of my documents when retrieving the same record using either the C++ driver or the Java driver.
Here is an example. Insert three…
I want to save a javascript code as store function via Java API. The problem is that I don't know how to convert String (type 2) to code (type 13). I know that in PHP it's possible:
new mongo.Code("function myFunction() { return 123; }").
So is…
I would like to implement a click counter using MongoDB (e.g. user clicks a link, count the total clicks).
My intuitive approach is to have an in-memory low priority thread pool that will handle a blocking queue of click messages and persist it to…
I am wondering if I can programmatically determine the health of the Replset through the Mongo Java Driver. What I want to know is: Where is the PRIMARY? How "caught up" are the SECONDARIES in oplog time? Is this possible and what's the API to…
currently I'm working on a project in Java, and I need to run the JavaScript Mongo queries using Java. I figured out I can do something like that using db.eval(). Problem is I have the following JavaScript query for Mongo and I have no idea how can…