Questions tagged [mongo-java-driver]

The Java driver for MongoDB

The MongoDB Java Driver.

Using the Java driver is very simple. First, be sure to include the driver jar mongo.jar in your classpath.

The following code snippets come from the QuickTour.java example code that can be found with the driver source.

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

Trying to update a document using MongoDB Java Driver

Thank you I just want to thank you for clicking on this question! I've tried my best to make this as thorough as possible. but still, feel free to let me know if you need to clarify anything further! if you think the question is too long. you can…
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
0 answers

Mongodb Write Performance goes down when Wired Tiger cache utilization goes above 80% of total cache size

I am running load test on Mongodb using java driver at client side. Cluster Setup includes: 3 Mongos, 3 Config Servers, 3 shards each having 3 members( Primary, Secondary and a Arbiter node).Everything is running on separate machine. Config…
2
votes
0 answers

Throwing error while parsing- org.bson.json.JsonParseException: Invalid escape sequence in JSON string '\Q'

I need to parse json string to Document to store in mongodb. When i am going to parse json string using Document.parse(jsonStr), if jsonstr contains "\" then it will throw org.bson.json.JsonParseException: Invalid escape sequence in JSON string…
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
1 answer

Setting Mongodb Connection Pool Options via mongo-java-driver Java API

Using Morphia and mongo-java-driver, I'm connecting to a mongo server: MongoClientOptions.Builder builder = MongoClientOptions.builder(); builder.sslEnabled(true); builder.sslInvalidHostNameAllowed(true); …
Saurabh Bhoomkar
  • 595
  • 1
  • 9
  • 29
2
votes
1 answer

Spring Data MongoDB @Transactional failure

Could someone please tell me why this spring transaction is not rolling back appropriately? The error I get is this: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type…
2
votes
0 answers

Mongodb aggregation query to java code

Can someone help me telling if the java code for the following query using Aggregates is correct or not? Mongo DB Shell Query: db.getCollection('xyz').aggregate([ { $match: { "try.Ind": "A", …
Shilpa
  • 101
  • 14
2
votes
3 answers

Connecting to MongoDB in Java

I'm following this tutorial to learn how to connect to MongoDB in Java, however, I'm encountering a problem and despite research, I can't seem to fix it. I do exactly what the tutorial tells me to do: Create a new Java project Add…
A.S.J
  • 627
  • 3
  • 14
  • 38
2
votes
1 answer

Mongo Java Driver 3.6.1 - How to parse a json array structured String to BasicDBList

When I use MongoDB 2.x.x I used (BasicDBList) JSON.parse("[]") to parse the string data to Document array. But the latest MongoDB driver says this is deprecated and the BasicDbObject.parse("") only converts to BasicDBObject. Here is some code…
Ajanthan
  • 198
  • 2
  • 10
2
votes
2 answers

MongoDB Scala - query document for a specific field value

So I know that in Mongo Shell, you use dot notation to get the field you want in any document. How is dot notation achieved in MongoDB Scala. I'm confused as to how it works. Here is the code that fetches a document from a collection: val record =…
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