Training Assignments: Java Se 8 Programming Language
Training Assignments: Java Se 8 Programming Language
Training Assignments: Java Se 8 Programming Language
Version 1.1
Hanoi, 04/2019
Lab Guides Java Basics Issue/Revision: x/y
RECORD OF CHANGES
Contents
Long Assignment 3 – Option 1: Building Database Application with JDBC......................................4
Objectives:.................................................................................................................................... 4
Product Architecture:.................................................................................................................... 4
Assignment Specifications:........................................................................................................... 5
Technical Requirements:.............................................................................................................. 5
Functional Requirements.............................................................................................................. 6
User Interface Requirements........................................................................................................6
CODE: JPL.L.A301
TYPE: LONG
LOC: 300
DURATION: 180 MINUTES
» Understand how to connect to database server and all components of JDBC APIs.
Product Architecture:
» The domain layer contains objects and logic related to our application.
» The persistence layer contains data access objects (DAO) that provide services for accessing
persistent data. DAO provide 4 basic services referred to as CRUD:
o Creaate: save new object data to the database.
o Retrieve: find object data in the database and recreate objects. There may be several
methods for this service to enable different forms of object lookup.
o Update: update data for an object already saved to the database.
Specifications:
Write a program that simulates the functions of the sales system.
Create a database named SMS for the sales system that has the following data tables:
Customer (customer_id, customer_name)
Employee (employee_id, employee_name, salary, supervisor_id)
Product (product_id, product_name, list_price)
Orders (order_id, order_date, customer_id, employee_id, total)
LineItem (order_id, product_id, quantity, price)
Notice that, all of the tables belong the same "dbo" schema.
Technical Requirements:
Create a project named JPL.L.A301_SMS will have the following packages:
o Default constructor and the constructor has 4 parameters to initialize value of attributes.
o Default constructor and the constructor has 2 parameters to initialize value of attributes.
o Default constructor and the constructor has 3 parameters to initialize value of attributes.
o Five private instance variables: orderId (int), orderDate (Date), customerId (int), employeeId
(int), total (double)
o Default constructor and the constructor has 5 parameters to initialize value of attributes.
Each entities will have its own interfaces and classe which are allocated inside fa.training.dao, follow the
following pattern: for interfaces (i.e OrderDAO, ProductDAO), for impl class (OrderDAOImpl,
ProductDAOImpl).
Functional Requirements
1) List all customers consist of customer id, customer name in the database, returns a list with all
customers in the order table (List<Customer> getAllCustomer() method).
2) List all orders consist of order id, order date, customer id, employee id, total for a customer, returns a
list with all the orders for a given customer id (List<Order> getAllOrdersByCustomerId(int
customerId) method).
3) List all lineitems for an order, returns a list with all line items for a given order id ( List<LineItem>
getAllItemsByOrderId(int orderId) method).
4) Compute order total, returns a list with a row containing the computed order total from the line items
(named as total_price) for a given order id. You must use an UDF (Double
computeOrderTotal(int orderId) method).
5) Add a customer into the database, you must use a Stored Procedure (boolean
addCustomer(Customer customer) method).
6) Delete a customer from the database, make sure to also delete Orders and OrderedProducts for the
deleted customer. You must use a Stored Procedure (boolean deleteCustomer(int
customerId) method).
7) Update a customer in the database, you must use a Stored Procedure (boolean
updateCustomer(Customer customer) method).
10) Update an order total into the database (boolean updateOrderTotal(int orderId) method).
Create a SaleManagement class that contains a main() method to test the above functional methods.
-- THE END --