Driver upgrade from 3.12.x to 4.9 mongodb-driver-legacy driver

Currently our application is developed using 3.12.x driver . I understand from the documentation there would not be any more development on this branch and mongo recommends to migrate to 4.x.

In 4.x , I see 2 different drivers maintained by Mongo

Using mongodb-driver-sync requires to use new API ( in our application which is a lot of effort.

If I use 4.9.1 mongodb-driver-legacy driver , can the old legacy API will continue to work seamlessly ? { Mongo server 4.4 } [ JFYI - I don’t intend to use any new features supported on the mongo server . There is a roadmap to move to 5.x and then to 6.x]. I don’t intend to making changes to application code or want to keep the changes to minimum.

What would I lose , if I continue to use mongodb-driver-legacy driver and not migrate to mongodb-driver-sync driver ?

What is the difference between the 2 driver flavours in 4.x train ? I have not been able to find any explanation regarding this.

Any help on this is much appreciated.

Hi @Udaya_Bhaskar_chimak,

Except for what’s mentioned in the Upgrading Guide, you should be able to upgrade your your application from 3.12 to 4.9 without any noticeable issues.

In terms of packaging, the legacy driver is more of a superset of the sync driver than an alternative to it. Both the legacy com.mongodb.MongoClient class and the com.mongodb.client.MongoClient interface have a getDatabase method that returns a com.mongodb.client.MongoDatabase instance, where new features are generally added. The main difference is that the legacy class also has a getDB method that returns a com.mongodb.DB instance. This is where the bulk of the “legacy” API lives and what is generally not enhanced with support for new features.

So if your application is already using MongoDatabase then making the switch to driver-sync is quite simple. But if it’s using DB, then it’s more complicated and likely easiest to just stay on driver-legacy.

Hope this helps.

Jeff Yemin

1 Like

Thanks a lot Jeff for your reply !

My Application code is written using DB. So I suppose, I will stay with driver-legacy for now to avoid the code changes.

I assume there would not be any performance-related issues with the the above usage . Hopefully Mongo internally tests the latest driver / server versions with this combination too.