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
2 answers

MongoDB find query with date comparison

In mongodb collection I saved date as a string. I want to fetch documents which were inserted in last 24 hours. Below is my code- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date yest = new Date(); Date now = new…
Sidd
  • 111
  • 1
  • 2
  • 8
0
votes
0 answers

mongodb(x86) stopping service while insert

I have large arrayList. I am trying to insert all list to mongodb by dividing 1000 items per inserting. But MongoDb service stops after inserting arround 900 000 records. I am getting this error: Unable to read data from the transport connection:…
Müslüm ÖZTÜRK
  • 961
  • 1
  • 11
  • 30
0
votes
2 answers

Mongodb compare two big data collection

I want to compare two very big collection, the main of the operation is two know what element is change or deleted My collection 1 and 2 have a same structure and have more 3 million records example : record 1 {id:'7865456465465',name:'tototo',…
timactive
  • 789
  • 6
  • 27
0
votes
1 answer

MongoDB + Java + Search to fetch field or column names only after searching a string in a document using either full text or regular search

I am am in need of a solution quickly for the following: Assuming that I have n numbere of documents in collection XYZ similar to below: XYZ{ NAME: Test AGE: 33 ADDRESS: ASDF EDUCATION: BSC } If I want to search for a string say: "BSC" I want the…
user2503105
  • 21
  • 1
  • 3
0
votes
1 answer

Unable to close connections in MongoDB - Java Driver

I am interacting with many db collections of MongoDB using Java driver. The queries are basically INSERT,DELETE and FETCH documents. Everything is working fine except the connections are open in the logs. Below is the log file Fri Dec 27…
Timothy Rajan
  • 1,947
  • 8
  • 38
  • 62
0
votes
2 answers

Problems using reflection with java-mongo driver

I'm trying this code http://ideone.com/gymUrP Object obj2 = coll.getClass().getMethod("find").invoke(coll, new Object[]{}); is working with an empty second argument (matching find() method) but I didn't manage to make the other methods work, like…
user1125394
0
votes
1 answer

MongoDB query invalid

I am using the database MongoDB and I trying to run a query that will check two things. The query is timestamp is greater than time and server is not equals to name. It would look like this in an if statement if (timestamp > date &&…
PHPDEV
  • 383
  • 1
  • 4
  • 12
0
votes
1 answer

$slice after apply $in to particular field in mongodb java to search data

In my mongodb data base i'm having the data like below format "_id": ObjectId("52b2802cd29e32f494463847"), "Name": "Hai2", "List": { "0": "72", "1": "46", "2": "94", "3": "13", "4": { "0":…
Suseendran P
  • 557
  • 1
  • 5
  • 18
0
votes
2 answers

MongoDB equivalent of SQL greatest()

I am in the process of changing the underlaying database from a relational database to MongoDB, and I need to "recreate" the same semantics through MongoDB queries. All in all, this is going fine, with the exception of one thing: the SQL greatest()…
Bendik
  • 928
  • 11
  • 23
0
votes
0 answers

mongodb stores large size documents and query is very slow

I store a very long string to my document in mongodb server, my document looks like { "_id": ObjectId("5280efdbe4b062c93b582118"), "viewID": 1, "content": "a very long string" } and there are about hundreds of such documents in the…
Engine Bai
  • 626
  • 1
  • 7
  • 16
0
votes
1 answer

Mongodb ldap authentication through Java driver

Does anyone have an example of how to authenticate to a mongodb 2.5 server (soon to be 2.6) with LDAP authentication using the Java driver?
Dave Wilkin
  • 231
  • 1
  • 3
  • 13
0
votes
0 answers

Can not retrieve file from gridFs using the java driver (but can using python)

NOTE; we've completely rewritten the backend in python now, so even though it would still be nice to know what we did wrong, it's not that big of a thing anymore. I've got a known file in my database that has the following objectID…
Lanting
  • 3,060
  • 12
  • 28
0
votes
1 answer

How to retrieve the schema of a DBObject?

In mySQL the describe statement can be used to retrieve the schema of a given table, unfortunately I could not locate a similar functionality for the MongoDB java driver :( Let's say I have I have the flowing BSON documents: { _id:…
SQL.injection
  • 2,607
  • 5
  • 20
  • 37
0
votes
1 answer

Mongo java driver : Prefer secondary mongo instance replica

I have a 3 members mongo replica-set over 2 diferent locations (connected via VPN). Here is the configuration : master, datacenter A slave1, priority 1, datacenter A slave2, priority 0, datacenter B With this conf, the master mongo instance will…
Salomon BRYS
  • 9,247
  • 5
  • 29
  • 44
0
votes
1 answer

DBCursor hasNext seems to only return 1 result when it should return 2

I have the following... DBCollection dbc = test.getCollection(); double count = dbc.count(); DBCursor cursor = dbc.find(); StringBuilder sb = new StringBuilder(); if( cursor.hasNext() ) sb.append(cursor.next().toString()); This outputs only one…
Jackie
  • 21,969
  • 32
  • 147
  • 289