This laboratory is dedicated to MongoDB, a document data store that belongs to the NoSQL family.
The main goal for this laboratory is to gain familiarity with a typical MongoDB use case. The interested student can understand the details of MongoDB by playing with the command line interface that interacts with the MongDB server. On the official website (http://www.mongodb.org/) it is possible to find the list of commands supported by MongDB, and additional useful documentation.
Installing and running the MongoDB server
MongoDB can be downloaded from the following webpage: https://www.mongodb.org/downloads
Put the downloaded file wherever you prefer, open a terminal, go to the directory where you put the downloaded file, then type the following commands
tar -xzf mongodb-linux-x86_64-2.6.5.tgz cd mongodb-linux-x86_64-2.6.5
sudo mkdir p /data/db
sudo ./bin/mongod
The last command will launch the server, and MongoDB is ready to accept connection on port 27017.
Interacting with the MongoDB server
In order to interact with the MongoDB server, a client is necessary. The client will connect to the server on port 27017 and it will send the commands through the connection. In this lab, we will use the Java client; these are the steps to follow for using such a client:
Download the jar of the Jedis client: http://central.maven.org/maven2/org/mongodb/mongo-java- driver/2.12.4/mongo-java-driver-2.12.4.jar
o alternatively, check this page http://docs.mongodb.org/ecosystem/drivers/java/
Put the jar in the same directory of your Java program;
In your Java program, import the Jedis class:
import com.mongodb.*;
In your Java program, use the Jedis client, e.g.:
MongoClient mongo = new MongoClient("localhost", 27017);
Compile your Java program:
javac -cp mongo-java-driver-2.12.4.jar myProgram.java
Run your Java program (that includes the Redis client):
java -cp '.: mongo-java-driver-2.12.4.jar' myProgram
The student can use as a starting point the file ecommerce_mongodb.java provided on the course web page. For additional information, check this web page: http://docs.mongodb.org/ecosystem/tutorial/getting-started-with-java-driver/
please solve them .