0% found this document useful (0 votes)
9 views4 pages

MongoDB Installation and Java Operations Guide

The document provides a step-by-step guide for downloading and installing MongoDB, including configuration as a Windows service and verification of installation. It also outlines operations such as creating a collection, inserting, finding, updating, and deleting employee records using Java code. Additionally, it includes instructions for creating a Java bean for employee information and testing it with a main class.

Uploaded by

Prachi Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

MongoDB Installation and Java Operations Guide

The document provides a step-by-step guide for downloading and installing MongoDB, including configuration as a Windows service and verification of installation. It also outlines operations such as creating a collection, inserting, finding, updating, and deleting employee records using Java code. Additionally, it includes instructions for creating a Java bean for employee information and testing it with a main class.

Uploaded by

Prachi Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Assignment–06

OBJECTIVE: Download MongoDB and execute following operations – CREATE,


INSERT, FIND, DELETE, UPDATE

PART–1

1. Download MongoDB Installer

 Visit the official MongoDB download page: MongoDB Installation Docs


 Choose the Community Edition (free version)
 Select the MSI installer for Windows
 Click Download

2. Run the Installer

 Double-click the downloaded .msi file


 Choose Complete Setup (recommended)
 Optionally, check the box to install MongoDB Compass (GUI tool)

3. Configure MongoDB as a Windows Service

 During installation, select the option to run MongoDB as a Windows service


 This allows MongoDB to start automatically with your system

4. Verify Installation

 Open Command Prompt and type: mongod --version


 You should see the installed version details

5. Start Using MongoDB

 You can interact with MongoDB using:


○ MongoDB Shell (mongosh)
○ MongoDB Compass (GUI)
 To start the shell, type:

mongosh

PART–2 Code:

use
companyDB;

CREATE:

[Link]("employees");

INSERT
// Access and print employee details
[Link]("Employee ID: " + [Link]());
[Link]("Name: " + [Link]());
[Link]("Department: " + [Link]());
[Link]("Email: " + [Link]());
[Link]("Salary: $" + [Link]());

3. Compile and Run

Use a terminal or command prompt:

javac [Link] [Link] java Main

output:

Employee ID: 101


Name: Alice
Department: Engineering
Email: alice@[Link]
Salary: $75000.0
Assignment – 7

Objective: Create a java bean for employee information

Code:

1. Save the Bean Class

Create a file named [Link] and paste the Java Bean code into it.

[Link] public class


Employee { private int id;
private String name; private
String department; private
String email; private double
salary; public Employee() {}

public Employee(int id, String name, String department, String email,


double salary) {
[Link] = id; [Link] = name;
[Link] = department;
[Link] = email;
[Link] = salary;
}

// Getters and setters…

2. Create a Main Class to Run It

Create another file named [Link] to test the Employee bean.

[Link] public
class Main { public
static void
main(String[] args)
{

// Create an Employee object using the parameterized constructor


Employee emp = new Employee(101, "Alice", "Engineering",
"alice@[Link]",
75000.0);

[Link]({

empID: 101, name: "Alice",

salary: 75000, designing:

"UI/UX", department: "Design"

});
// FIND

[Link]({

empID: 101 });

// UPDATE

[Link]({

empID: 101 },

{ $set: { salary: 80000 } }

);

// DELETE

[Link]({

empID: 101 });

OUTPUT:

css

Copy code

Found: {

_id: new

ObjectId(".."), empID:

101, name: "Alice",

salary: 75000,

designing: "UI/UX",

department: "Design"

You might also like