MongoDB Atlas connection

Hi - I am trying to follow the tutorial on mongo db at : https://docs.liquibase.com/workflows/database-setup-tutorials/mongodb.html
The problem is in the example, it conencts to a local mongodb deployment and I want to connect to Mongo Atlas.

In the liquibase.properties file the advise is to put - “url: mongodb://hostname:27017/myDatabase”

However, Atlas URL should be “mongodb+srv://hostname:27017/myDatabase”

Liquibase does not seem to like this, it throws an exception:

Cannot find database driver: Driver class was not specified and could not be determined from the url

Surely connecting to mongo atlas should be possible? Please guide me as to how?

Thanks

Hi @spozza,

MongoDB support is provided by Liquibase extension, which means the additional functionality for the db platform is provided by the community (and is a good candidate for being pulled into liquibase core if it aligns).

I’ve never seen MongoDB Atlas being used, and so, I would recommend logging an issue so the maintainer can give the definitive response as to support, or add it if not present:

HTH,

Ronak

Thanks that helps

I did figure this out and the solution is to just use an older style url to connect it to atlas (without the srv bit) which does the job

OMG, that’s awesome @spozza,

Favor please: Would you share the format? Is it just the TLS arg in the Url?

I am so happy you got it working!

Ronak

yeah sure. So the atlas connections have the “+SRV” syntax which first problem is that it confuses the driver auto detection

To resolve, I used a backward compatible connection string like this:

mongodb://username:password@some-cluster-shard-00-00.XXXXX.mongodb.net:27017/?ssl=true&replicaSet=some-cluster-shard-0&authSource=admin&retryWrites=true&w=majority

This successfully recognizes the driver and also makes the connection.
I checked with mongo if this format was likely to be deprecated at any stage and they said very unlikely

Maybe this will help someone else someday :slight_smile:

Cheers