Questions tagged [mongodb-java]

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.

Java Language Center

Java Driver

Basics

Specific Topics and How-To

Reference

1045 questions
0
votes
1 answer

MongoDB Java Driver Infinite loop while reading results

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 =…
user1965449
  • 2,849
  • 6
  • 34
  • 51
0
votes
1 answer

What is the best practice for joins in MongoDB?

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…
hellzone
  • 5,393
  • 25
  • 82
  • 148
0
votes
1 answer

MongoInternalException: DBPort.findOne failed while running on GAE localserver

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…
sharath
  • 3,501
  • 9
  • 47
  • 72
0
votes
2 answers

CSV to GeoJSON conversion

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…
koustubhC
  • 157
  • 2
  • 15
0
votes
1 answer

Play Framework for Java 2.1 and MongoDB

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…
0
votes
1 answer

mongodb queries in Java

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…
kunal18
  • 1,935
  • 5
  • 33
  • 58
0
votes
1 answer

MongoDb java async driver : What is the correct query for sorting and limiting values from a collection

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…
Abhilash PS
  • 734
  • 1
  • 11
  • 25
0
votes
2 answers

mongodb Queries: How to get nested Data on a Spark/Freemarker page?

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…
Jeff
  • 4,285
  • 15
  • 63
  • 115
0
votes
1 answer

MongoDB with a Tomcat v7 Java Server

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…
David K.
  • 679
  • 2
  • 10
  • 23
0
votes
1 answer

Netty HTTP + MongoDB: Unlimited Increment in connections

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…
Cheng
  • 47
  • 2
  • 6
0
votes
2 answers

MongoDB - Inconsistent representation of binary data using C++ and Java drivers

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…
0
votes
1 answer

Save a javascript code as store function via Java API

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…
St.
  • 521
  • 3
  • 8
0
votes
1 answer

Click counter implementation with MongoDB - asynchronous write

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…
Eran Medan
  • 44,555
  • 61
  • 184
  • 276
0
votes
1 answer

Can I programmatically determine the health of the ReplSet (Java Driver)

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…
Bob Kuhar
  • 10,838
  • 11
  • 62
  • 115
0
votes
2 answers

mongodb javascript queries

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…
diba6122
  • 31
  • 1
  • 7