I try connect mathematica with my database NOSQL mongoDB but I have problem with create collection. I have Mathematica 10.2 and I download driver .net version 2.2 from this website a link! I unpacking driver to :
input : FileNameJoin[{$InstallationDirectory, "SystemFiles", "Links", "NETLink"}]
output : "C:\\Mathematica\\SystemFiles\\Links\\NETLink"
After unpacking zip folder to "C:\Mathematica\SystemFiles\Links\NETLink" I install this pack and I connect to database and try createCollection but i have problem this is my code with output:
In[2]:= InstallNET[]
Out[2]= LinkObject["C:\\Mathematica\\SystemFiles\\Links\\NETLink\\\InstallableNET.exe", 127, 4]
In[13]:= conn = ConnectToMongoDB["localhost"]
Out[13]= NETLink`Objects`NETObject$377462395502593
In[5]:= GetMongoServer[conn_] := Module[{}, conn@GetServer[]]
In[6]:= createCollection[conn_, db_String, collectionname_String] := Module[{server, database},
server = GetMongoServer[conn];
database = server@GetDatabase[db];
database@CreateCollection[collectionname]
]
In[8]:= createCollection[conn, "mydb", "test"]
During evaluation of In[8]:=
NET::nomethod: No public instance method named GetServer exists for the .NET type MongoDB.Driver.MongoClient.
Out[8]= $Failed[GetDatabase["mydb"]][CreateCollection["test"]]
I use MongoDB on Windows and I switch to mydb
> use mydb
switched to db mydb
I have no idea what I'm doing wrong maybe some suggestions?
I must use only mathematica because I write engineering work about database connections and I must to use java or .Net. Thank you for this link b.gatessucks but when I use database link in java I have problem this problem:
In[1]:= << MongoDBLink`
In[4]:= conn = OpenConnection[];
In[5]:= DatabaseNames[conn]
Out[5]= {"local"}
In[18]:= db = GetDatabase[conn, "local"]
In[19]:= CollectionNames[db]
Out[19]= {"name", "startup_log"}
In[20]:= coll = GetCollection[db, "name"]
In[21]:= InsertDocument[coll, {"a" -> #, "b" -> 2 #}] & /@ Range[5]
Out[21]= {0, 0, 0, 0, 0}
In[23]:= FindDocuments[coll]
During evaluation of In[23]:= Java::excptn: A Java exception occurred: java.lang.UnsupportedClassVersionError: MongoDBLinkUtils : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source).
During evaluation of In[23]:= LoadJavaClass::fail: Java failed to load class MongoDBLinkUtils. >>
Out[23]= MongoDBLinkUtils`Iterate[JLink`Objects`vm1`\
JavaObject11819681379778561]
GetServer[]
. Have you read the driver docs? $\endgroup$