Bda Experiment No 9
Bda Experiment No 9
TECHNOLOGY
DEPT. OF COMPUTER ENGINEERING
EXPERIMENT NO: 9
Aim: To Study and Configure mongodb with eclipse and run sample
project
Theory:
Eclipse is an IDE (integrated development environment) used in computer
programming. Eclipse is an IDE in which we can use any type of
programming language for which plugins are available. It contains a base
workspace and an extensible plug-in system for customizing the
environment. Eclipse is free and open-source software. It is written in Java
and is considered to be the most popular Java IDE. It works on all main
platforms, including Linux, Windows, Mac OS, etc., and has many
powerful features that can be used to work out in many projects. It also
provides documentation and modeling support and offers UML, OCL,
SysML, and implementation tools. Besides that, it provides support for Git,
Apache Maven, Gradle, etc.
Features of Eclipse
It allows setting breakpoints.
Automatically validates syntax.
Offers a robust debugger.
Provides you with readymade code templates.
Robust java editor.
It supports code refactoring.
It supports syntax coloring.
To find out more about Eclipse and its setup process, you can have a look here.
MongoDB
MongoDB is an open-source platform that is a document-oriented
programming language (NoSQL database). And it is the leading database in
NoSQL. MongoDB is written in c++. As it is a NoSQL database, it uses JSON-
like documents to store the data in the database.
Advantages of MongoDB
It is easy to set up MongoDB on your PC.
MongoDB is a schema-less database, so there won’t be any problem with
Schema Migration.
It is very easily scalable.
It helps in providing fast access to data because of its nature of
implementing internal memory to store the data.
As it is a document-oriented language, document queries are used, which
YADAVRAO TASGAONKAR INSTITUTE OF ENGINEERING
& TECHNOLOGY
DEPT. OF COMPUTER ENGINEERING
Click on Add External JAR and add mongo-java-driver from where you
have downloaded it.
Now click on Apply and close.
Now right, click on the MongoDB_with_Java project and create a class.
Add all the necessary libraries in the class to write the java program to
use the Mongo DB in eclipse.
Example:
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.MongoClient; //including essential libraries
catch (Exception e) {
System.out.println("error"); // if the exception occurs prints error
}
System.out.println("server ready"); // if there is no exception prints server
ready
}
}
We will establish a server connection with localhost, and then we will create a
database with the name Student. If the database is created, then it will give
output as the database created, and if an exception occurs, it will print an error.
YADAVRAO TASGAONKAR INSTITUTE OF ENGINEERING &
TECHNOLOGY
DEPT. OF COMPUTER ENGINEERING
Conclusion:
So that we can create a new database, manage the database, and do all the
operations on the database in eclipse using MongoDB. You can learn more
about MongoDB by following this Mongo DB tutorial.
YADAVRAO TASGAONKAR INSTITUTE OF ENGINEERING &
TECHNOLOGY
DEPT. OF COMPUTER ENGINEERING