Closed mmpataki closed 1 year ago
Hi @mmpataki,
In the [documentation for the MongoDB URI|https://docs.mongodb.com/manual/reference/connection-string/], you'll see that the database name after the /
is not actually a database to connect to, but rather the default auth database.
The JDBC driver allows users to specify the database to connect to via the database
key in the Properties
object passed into the MongoConnection
constructor.
Hi @rychipman I believe there should be a way to pass those props via connection string which is not possible without this patch applying this patch allows one to pass dbname through connection string
Users sometimes don't have luxury of passing a props object eg. external library and this shouldn't cause a NPE. Please check the test i added
@rychipman @mmpataki I'm in favor of supporting this, but we should talk to product
@pmeredit @rychipman you guys had a discussion?
I am pretty sure you can do this, right? In my app I am connecting like this:
sample
database, using admin
database to check credentialsmongodb://root:password@localhost:27017/sample?authSource=admin
@mmpataki We've decided to match the way the drivers handle the default database in the URI, i.e. mongodb://server/db?authSource=admin&otherProps
, see #122 . cc @nbagnard and @pmeredit
Closing this issue as #122 resolves this. Users will be able to specify a default db in the URI on the next release.
Database name specified in the connection string is not honored. With this change one can specify a db name as jdbc:mongodb://foo:foopass@localhost:27017/admin?database=mydatabase