mongo-java-driver

Change default Mongo connection pool size in spring-boot

两盒软妹~` 提交于 2020-07-20 16:18:47
问题 I want to change the default size of connection pool provided by java mongodb driver which is 100 according to mongo docs. Below is the mongo client bean which I used to customize the connection pool size (refered this question). I set both min and max connectionPerHost attributes to 1 and ran 10 parallel worker threads which interact with the DB to make sure that my change is applied. @Bean public Mongo mongo() throws Exception { MongoClientOptions.Builder clientOptions = new

Change default Mongo connection pool size in spring-boot

↘锁芯ラ 提交于 2020-07-20 16:16:31
问题 I want to change the default size of connection pool provided by java mongodb driver which is 100 according to mongo docs. Below is the mongo client bean which I used to customize the connection pool size (refered this question). I set both min and max connectionPerHost attributes to 1 and ran 10 parallel worker threads which interact with the DB to make sure that my change is applied. @Bean public Mongo mongo() throws Exception { MongoClientOptions.Builder clientOptions = new

Change default Mongo connection pool size in spring-boot

陌路散爱 提交于 2020-07-20 16:16:13
问题 I want to change the default size of connection pool provided by java mongodb driver which is 100 according to mongo docs. Below is the mongo client bean which I used to customize the connection pool size (refered this question). I set both min and max connectionPerHost attributes to 1 and ran 10 parallel worker threads which interact with the DB to make sure that my change is applied. @Bean public Mongo mongo() throws Exception { MongoClientOptions.Builder clientOptions = new

Java8 - How does explicit type matches one variant - not other type?

好久不见. 提交于 2020-06-16 03:02:10
问题 I have a simple snippet as below. I referred this List<Document> list = new LinkedList<Document>(); FindIterable<Document> itr = collection.find(findQuery) .forEach((Document doc) -> list.add(doc)); return list; It compiles without any issues. I guess that we are telling compiler that doc is of type Document . Why is it needed? But If I do the below, it throws ambiguous error. I referred this But couldn't relate and understand exactly. collection.find(findQuery).forEach(list::add); Could

Java MongoDB save multiple documents at once

帅比萌擦擦* 提交于 2020-06-08 11:15:40
问题 I Have a list of updated objects/documents i need save all the objects in the list at once. I saw save() in MongoTemplate but it can take single document at a time. Is there any way to save multiple documents at once or i need to call save in loop ? 回答1: Thanks for all the help. I was able to do it using Spring data MongoDB. Spring data MongoDB's MongoRepository has many inbuilt methods. org.springframework.data.mongodb.repository.MongoRepository.saveAll(Iterable entites) is the one which i

How to call db.Collection.stats() from Mongo java driver using MongoClient class

妖精的绣舞 提交于 2020-04-18 02:43:21
问题 I am using this dependency. <dependency> <groupId>org.mongodb</groupId> <artifactId>mongodb-driver</artifactId> <version>3.12.2</version> </dependency> Package: package com.mongodb.MongoClient; How can I get collection by name then get its status so that the following information will be available: size storageSize Collection Status It seems that the answer for this How to call db.Collection.stats() from Mongo java driver uses deprecated class package com.mongodb; // Mongodb initialization

How to call db.Collection.stats() from Mongo java driver using MongoClient class

主宰稳场 提交于 2020-04-18 02:38:53
问题 I am using this dependency. <dependency> <groupId>org.mongodb</groupId> <artifactId>mongodb-driver</artifactId> <version>3.12.2</version> </dependency> Package: package com.mongodb.MongoClient; How can I get collection by name then get its status so that the following information will be available: size storageSize Collection Status It seems that the answer for this How to call db.Collection.stats() from Mongo java driver uses deprecated class package com.mongodb; // Mongodb initialization

MongoDb BSON stores Date in UTC time

允我心安 提交于 2020-04-10 02:56:03
问题 If I try to put a date field in a Document (BSON) and write it to Mongo, BSON writes it in UTC. For example, a date DateTime dateTime = new DateTime("2015-07-01"); Document doc = new Document("date", dateTime.toDate()); will be stored as "date" : ISODate("2015-06-30T18:30:00Z") in Mongo. And, if I retrieve it using the same Java Driver I get it as Wed Jul 01 00:00:00 IST 2015 Great. Is there no solution to this? I mean, why can't I store my date as I want it? What If I need to query on the DB

MongoDb BSON stores Date in UTC time

走远了吗. 提交于 2020-04-10 02:55:13
问题 If I try to put a date field in a Document (BSON) and write it to Mongo, BSON writes it in UTC. For example, a date DateTime dateTime = new DateTime("2015-07-01"); Document doc = new Document("date", dateTime.toDate()); will be stored as "date" : ISODate("2015-06-30T18:30:00Z") in Mongo. And, if I retrieve it using the same Java Driver I get it as Wed Jul 01 00:00:00 IST 2015 Great. Is there no solution to this? I mean, why can't I store my date as I want it? What If I need to query on the DB

MongoDb BSON stores Date in UTC time

﹥>﹥吖頭↗ 提交于 2020-04-10 02:54:10
问题 If I try to put a date field in a Document (BSON) and write it to Mongo, BSON writes it in UTC. For example, a date DateTime dateTime = new DateTime("2015-07-01"); Document doc = new Document("date", dateTime.toDate()); will be stored as "date" : ISODate("2015-06-30T18:30:00Z") in Mongo. And, if I retrieve it using the same Java Driver I get it as Wed Jul 01 00:00:00 IST 2015 Great. Is there no solution to this? I mean, why can't I store my date as I want it? What If I need to query on the DB