Question: Instructions: This exam consists of writing a Java program that incorporates concepts from collections, multi - threading, and database connectivity. You are required to use
Instructions:
This exam consists of writing a Java program that incorporates concepts from collections, multithreading, and database connectivity.
You are required to use proper coding conventions and documentation.
Your program should be wellstructured and demonstrate a clear understanding of the specified topics.
Marks will be awarded for correctness, efficiency, and clarity of the code.
Problem Statement:
You are tasked with developing a multithreaded Java program to manage a simple inventory system. The program should use a collection to store information about products and their quantities. Additionally, the program should implement multithreading to simulate concurrent transactions that involve updating the inventory. Finally, the program should establish a database connection to store and retrieve product information. Requirements:
Collections marks:
Create a class named 'Product' with attributes: 'productid', productName, and 'quantityOnHand.
Implement a collection eg ArrayList to store instances of the 'Product' class.
Include methods to add a new product, update product quantity, and display the current inventory.
Multithreading marks:
Implement a class named 'Transaction' that extends 'Thread'.
The 'Transaction' class should have a method to simulate a purchase transaction, which involves updating the quantity of a random product in the inventory.
Create at least two instances of the 'Transaction' class and run them concurrently to demonstrate multithreading.
Database Connectivity marks:
Establish a connection to a database you can use any database of your choice
Create a table to store product information, including 'productid', 'productName', and 'quantityOnHand'.
Modify your program to use the database to store and retrieve product information.
Documentation and Code Quality marks:
Provide clear and concise comments throughout your code.
Follow proper coding conventions.
Ensure that your code is wellorganized and easy to understand.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
