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.
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…
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:…
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',…
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…
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…
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…
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 &&…
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":…
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()…
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…
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…
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:…
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…
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…