Some useful links:
Questions tagged [mongo-java]
315 questions
3
votes
3 answers
MongoDB Java Driver - Use exists projection in find query
I want to get all documents where the field download does not exists
find{ "download" : {$exists: false}}
For Java I found an Example:
BasicDBObject neQuery = new BasicDBObject();
neQuery.put("number", new BasicDBObject("$ne", 4));
DBCursor…

Dukeatcoding
- 1,363
- 2
- 20
- 34
3
votes
2 answers
MongoDB configuration in a java web app
I'm looking for some advice on the proper way to set up mongoDB for my web application that runs with java.
From the mongoDB tutorial, i understand that I should have only one instance of the Mongo class.
The Mongo class is designed to be thread…

jonasr
- 1,876
- 16
- 18
2
votes
0 answers
MongoDB connection URI for SSL
I'm working on JDK8 and using mongo-java-driver(v3.5.0) to connect MongoDB(v3.6.3).
I've enabled SSL by following this article. I don't have /etc/mongod.conf file, instead I've /etc/mongodb.conf file; so I've updated the SSL settings in that file:
#…

dev-eloper
- 110
- 11
2
votes
1 answer
Java - Insert/Update with MongoDB collection bulkWrite
I am very new to MongoDB. Trying to understand the best option to perform Bulk Write in MongoDB. I want to periodically refresh my Application collection. The key's for documents are AppID, AppName and AppStatus.
Below are the actions I want to…

Shibankar
- 806
- 3
- 16
- 40
2
votes
1 answer
How to specify UUID in mongo $where clause
I have an object that was stored via mongo-java-driver. Object uses java.util.UUID for its _id field. Following is presentation of object via mongo shell:
> db.b.find()
{ "_id" : BinData(3,"zUOYY2AE8WZqigtb/Tqztw==") }
I have a requirement to…

Raman
- 887
- 4
- 12
- 28
2
votes
1 answer
MongoDB random exception
We are using MongoDB v4.2 on IBM Cloud over the Reactive MongoDB Driver v1.11.
We are currently experiencing the following exception randomly, usually after some period of the app inactivity:
com.mongodb.MongoSocketWriteException: Exception sending…

archie_by
- 1,623
- 2
- 11
- 10
2
votes
1 answer
Using lookup pipelines with Java Async Driver
Tying to get a lookup working with the async java driver to join 2 collections. But I can't figure out the correct syntax to use as I can't find any documentation on what the syntax is using the Let (variables) version of the $lookup command is to…

Marc Olin
- 59
- 7
2
votes
1 answer
Mongo java driver says top level classes with generic types are not supported by PojoCodec
I am trying to use the MongoDB Reactive Streams Java Driver 1.11, moving off https://jongo.org/. It seems to be using https://mongodb.github.io/mongo-java-driver/3.10/. I have a bunch of other registered classes that are working fine. I have looked…

user1145925
- 971
- 3
- 13
- 24
2
votes
2 answers
How to connect MongoDB via JNDI in java
Currently i am using the following code for connecting into MongoDB via java.
MongoClientURI uri = new MongoClientURI("mongodb://10.0.8.78:27017/mydb");
MongoClient mongoClient = new MongoClient(uri);
I want to create MongoClient object…

Nandu
- 151
- 1
- 2
- 12
2
votes
2 answers
MongoDB - Implementing nor query in java
I have the following query which I am trying to implement in Java (I am using 3.4.2 mongo-java driver) :
Json:
{
"_id" : "Team:2334918",
"fieldName" : [
"Delivery",
"Support"
],
…

Saurabh
- 930
- 2
- 17
- 39
2
votes
1 answer
Mongo JAVA driver-3.6 iterator() iterating over a single document again and again
I am trying to update every documents "Name" field in the collection using the iterator() defined in the FindIterable interface in Java Mongo driver. The next() function on the iterator should give me the next BSON object, but actually, it's…

Anu
- 3,198
- 5
- 28
- 49
2
votes
1 answer
How to create Decimal128 field with inc operator in java/scala
I have following document structure:
{
"moneys": {
"someKey": NumberDecimal(99)
...
"someOtherRandomKey": NumberDecimal(99)
}
{
What I want: When nonexistent field increments, create that field with
NumberDecimal value.
I…

zella
- 4,645
- 6
- 35
- 60
2
votes
1 answer
Mongo Java Client: How can I connect with SSL enabled but no certificate?
For testing I have setup a mongodb server which allows for ssl connections without certificate. I am able to connect in this way using RoboMongo and the mongo-c-driver, however when I try Java I get:
{javax.net.ssl.SSLHandshakeException:…

sagioto
- 251
- 1
- 5
- 16
2
votes
1 answer
Find documents with array that contains a specific value in mongodb using java
According to the answer provided in this link: Find document with array that contains a specific value, i have tried getting the items in java using this statement
searchQuery.put("arrayMine", new…

Chit Khine
- 830
- 1
- 13
- 34
2
votes
1 answer
How to filter documents based on an embedded array?
After reviewing this page, specifically this query
db.scores.find(
{ results: { $elemMatch: { $gte: 80, $lt: 85 } } }
)
I used the following imports
import static com.mongodb.client.model.Filters.and;
import static…

Muhammad Gelbana
- 3,890
- 3
- 43
- 81