how to access mongoDB from Matlab

조회 수: 6 (최근 30일)
Victor Yi
Victor Yi 2016년 3월 11일
답변: Neil Caithness 2017년 5월 18일
I'm trying to access mongoDB from Matlab through Java driver, but it seems Matlab could not find MongoClient class.
>> javaaddpath('mongodb-driver-3.2.2.jar');
>> import com.mongodb.*;
>> mc = MongoClient(server, port);
Undefined function or variable 'MongoClient'.
>> import com.mongodb.MongoClient;
Error using import Import argument 'com.mongodb.MongoClient' cannot be found or cannot be imported.

채택된 답변

Neil Caithness
Neil Caithness 2017년 5월 18일
Using version 3.4.2 of the Java driver I have success with this:
MongoDB Atlas instances will tell you the properly formatted URI.
uristr = 'mongodb://<USERNAME>:<PASSWORD>@cluster0-shard-00-00-...';
uri = MongoClientURI( uristr );
mc = MongoClient( uri );
db = mc.getDatabase( database );

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by