Reputation: 5745
According to mongodb java concurrency driver we can use one instance of MongoClient
for multiple threads for example inside application servers. The only way I know to do this is to create MongoClient
in static block:
static {
MongoClient mongoClient = new MongoClient("localhost", 27017);
}
the problem is I can't catch MongoException
and return some helpfull information to user. So how to share a single instance of MongoClient
between multiple threads inside Java EE application servers?
Upvotes: 0
Views: 1610
Reputation: 3631
You can do one of the following:
Upvotes: 1