mongodbscalacasbahscala-2.11

what is the difference between MongoClient and MongoConnection


i want to know what is the difference between mongoClient and mongoConnection and what is the difference between these two codes

  serverAddress=new ServerAddress("Localhost",27017)
           client= MongoClient(serverAddress)
           testDB = client("testdb")//get database Name
           collection = testDB("mycol")//get collection Name 

and

 serverAddress=new ServerAddress("Localhost",27017)
           con= MongoClient(serverAddress)
           testDB = con("testdb")//get database Name
           myCollection = testDB("mycol")//get collection Name 

please explain what is the difference


Solution

  • MongoConnection has been deprecated in favor of MongoClient. To my knowledge there was no difference at the time MongoClient was introduced. I guess the functionality may diverge over time.

    From the API tutorial: Casbah API tutorial

    "MongoClient was added to the Java driver in 2.10 as the default connection class for MongoDB. Older Casbah code may use MongoConnection which should be updated to use MongoClient."