I want to create a connection to my database in MongoDB from Matlab R2015a. I have tried with both the drivers for C# and Java but none of them seem to work and I don't know what the problem is.
For Java:
Code:
javaaddpath('/%path%/mongodb-driver-3.0.0.jar')
import com.mongodb.*;
mongoClient = MongoClient();
db = mongoClient.getDB('myDB');
colls = db.getCollectionNames();
coll = db.getCollection('myCollection');
Error:
No appropriate method, property, or field 'getDB' for class 'MongoDB.Driver.MongoClient'.
For C#:
Code:
NET.addAssembly('%path%\CSharpDriver-2.0.0\MongoDB.Driver.dll');
import MongoDB.Driver.*;
mongoClient = MongoDB.Driver.MongoClient();
mongoServer = mongoClient.GetServer();
db = mongoClient.GetDatabase('myDB');
collection = db.GetCollection('myCollection');
Errors:
1. No appropriate method, property, or field 'GetServer' for class 'MongoDB.Driver.MongoClient'.
2. If I comment the GetServer line I get: No appropriate method, property, or field 'GetCollection' for class 'MongoDB.Driver.MongoDatabaseImpl'.
I don't know if I am missing something and it would be really helpful if I could make it work.
I have also tried with the driver for Matlab but I couldn't make it create the .dll. Thanks.