Activity 2: Modify a Java program to do the following Program provided below. Starting with the…

Activity 2:Modify a Java program to do the following Program provided below. Starting with the JavaSimpleExample.java code in your sample source code, modify it to do the following: 1. Rename the program ser322.eclab.Activity2 2. Modify the seedData.add calls to add one single new Document to the story database matching the structure of documents you see in that database (for example, returned by Activity 1 #3). You may choose what the values are for each field as long as you do not copy an existing document. 3. Modify the connection information for the client so that the code uses the

question Activity 2:Modify a Java program to do the following Program provided below. Starting with the JavaSimpleExample.java code in your sample source code, modify it to do the following: 1. Rename the program ser322.eclab.Activity2 2. Modify the seedData.add calls to add one single new Document to the story database matching the structure of documents you see in that database (for example, returned by Activity 1 #3). You may choose what the values are for each field as long as you do not copy an existing document. 3. Modify the connection information for the client so that the code uses the right database and the right collection. 4. Do the insert of the seedData from #2 5. Execute a query and print out the results equivalent to Activity 1 #6 6. Execute a query and print out the results equivalent to Activity 1 #8 Make sure all of your cursors and clients are closed JAVA Program to exit package simple; import java.net.UnknownHostException; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; import com.mongodb.ServerAddress; import com.mongodb.client.MongoDatabase; import com.mongodb.client.MongoCollection; import org.bson.Document; import java.util.Arrays; import com.mongodb.Block; import com.mongodb.client.MongoCursor; import static com.mongodb.client.model.Filters.*; import com.mongodb.client.result.DeleteResult; import static com.mongodb.client.model.Updates.*; import com.mongodb.client.result.UpdateResult; import java.util.ArrayList; import java.util.List; public class JavaSimpleExample { public static void main(String[] args) throws UnknownHostException{ // Create seed data ListseedData = new ArrayList(); seedData.add(new Document(“decade”, “1970s”) .append(“artist”, “Debby Boone”) .append(“song”, “You Light Up My Life”) .append(“weeksAtOne”, 10) ); seedData.add(new Document(“decade”, “1980s”) .append(“artist”, “Olivia Newton-John”) .append(“song”, “Physical”) .append(“weeksAtOne”, 10) ); seedData.add(new Document(“decade”, “1990s”) .append(“artist”, “Mariah Carey”) .append(“song”, “One Sweet Day”) .append(“weeksAtOne”, 16) ); // Standard URI format: mongodb://[dbuser:dbpassword@]host:port/dbname MongoClientURIuri = new MongoClientURI(“mongodb://localhost:27017/simple”); MongoClient client = new MongoClient(uri); MongoDatabasedb = client.getDatabase(uri.getDatabase()); /* * First we’ll add a few songs. Nothing is required to create the * songs collection; it is created automatically when we insert. */ MongoCollection songs = db.getCollection(“songs”); // Note that the insert method can take either an array or a document. songs.insertMany(seedData); /* * Then we need to give Boyz II Men credit for their contribution to * the hit “One Sweet Day”. */ Document updateQuery = new Document(“song”, “One Sweet Day”); songs.updateOne(updateQuery, new Document(“$set”, new Document(“artist”, “Mariah Carey ft. Boyz II Men”))); /* * Finally we run a query which returns all the hits that spent 10 * or more weeks at number 1. */ Document findQuery = new Document(“weeksAtOne”, new Document(“$gte”,10)); Document orderBy = new Document(“decade”, 1); MongoCursor cursor = songs.find(findQuery).sort(orderBy).iterator(); try { while (cursor.hasNext()) { Document doc = cursor.next(); System.out.println( “In the ” + doc.get(“decade”) + “, ” + doc.get(“song”) + ” by ” + doc.get(“artist”) + ” topped the charts for ” + doc.get(“weeksAtOne”) + ” straight weeks.” ); } } finally { cursor.close(); } // Since this is an example, we’ll clean up after ourselves. //songs.drop(); // Only close the connection when your app is terminating client.close(); } }

Custom Paper Help
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.