public abstract class MongoDbUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
closeDB(com.mongodb.DB db)
Deprecated.
since 1.7. The main use case for this method is to ensure that applications can read their own
unacknowledged writes, but this is no longer so prevalent since the MongoDB Java driver version 3
started defaulting to acknowledged writes.
|
static com.mongodb.DB |
getDB(com.mongodb.Mongo mongo,
String databaseName)
Obtains a
DB connection for the given Mongo instance and database name |
static com.mongodb.DB |
getDB(com.mongodb.Mongo mongo,
String databaseName,
UserCredentials credentials)
Deprecated.
since 1.7. The
MongoClient itself should hold credentials within
MongoClient.getCredentialsList() . |
static com.mongodb.DB |
getDB(com.mongodb.Mongo mongo,
String databaseName,
UserCredentials credentials,
String authenticationDatabaseName)
Deprecated.
since 1.7. The
MongoClient itself should hold credentials within
MongoClient.getCredentialsList() . |
static boolean |
isDBTransactional(com.mongodb.DB db,
com.mongodb.Mongo mongo)
Return whether the given DB instance is transactional, that is, bound to the current thread by Spring's transaction
facilities.
|
public static com.mongodb.DB getDB(com.mongodb.Mongo mongo, String databaseName)
DB
connection for the given Mongo
instance and database namemongo
- the Mongo
instance, must not be null.databaseName
- the database name, must not be null or empty.DB
connection@Deprecated public static com.mongodb.DB getDB(com.mongodb.Mongo mongo, String databaseName, UserCredentials credentials)
MongoClient
itself should hold credentials within
MongoClient.getCredentialsList()
.DB
connection for the given Mongo
instance and database namemongo
- the Mongo
instance, must not be null.databaseName
- the database name, must not be null or empty.credentials
- the credentials to use, must not be null.DB
connection@Deprecated public static com.mongodb.DB getDB(com.mongodb.Mongo mongo, String databaseName, UserCredentials credentials, String authenticationDatabaseName)
MongoClient
itself should hold credentials within
MongoClient.getCredentialsList()
.mongo
- databaseName
- credentials
- authenticationDatabaseName
- public static boolean isDBTransactional(com.mongodb.DB db, com.mongodb.Mongo mongo)
db
- the DB to checkmongo
- the Mongo instance that the DB was created with (may be null
)@Deprecated public static void closeDB(com.mongodb.DB db)
db
- the DB to close (may be null
)Copyright © 2011-2015–2015 Pivotal Software, Inc.. All rights reserved.