I ran into the problem of multivolume MongoDB. I have two different mongoDB databases (db1 and db2). They have different credentials.
db1 credentials :
userName: admin
password: passwd
db2 credentials :
username: admin1
password: passwd1
I need to switch from one database to another at runtime. I have an autwired mongoTemplate with db1 credentials, but now I cannot update the template with db2 credentials. Is it possible? If so, how? If not, tell me another way to switch databases at runtime with different credentials.
Note what I know about "SimpleMongoDbFactory". You can extend "SimpleMongoDbFactory" and can override the "getDb" method and pass the required dbName name to super.getDb ("dbName") for layering. But this does not work with two databases with different credentials.
source share