Final Exam, Fall,
Open books, handouts, solutions, etc., closed electronic devices.
Problems are marked with points, Total points = 150.
Note the music project database schema on the last page, for reference.
1. (15) Important Examples
a. In the Download application of Chapter 7, available in project ch07download, there are these notable components:
A servlet, DownloadServlet.java M V C
File-accessing code, UserIO.java M V C
Various JSP files M V C
This is an MVC application, although not as layered as our main projects. Classify these parts of the application by circling M for model, V for view and C for controller.
b. In the Cart application of Chapter 7, available in project ch07cart, allowed a user to manipulate the contents of a shopping cart, adding, removing, and updating its items on various requests. Through what mechanism provided by tomcat (and other application servers) is an app allowed to keep around an object in memory through the various requests by one user. Specifically:
Brief description of how it works, and what software in involved:
2. (15) Concurrency Suppose a MVC web application (pizza3 or music3) running in tomcat has 6 user sessions active, and of these, 3 (with all different users) are doing concurrent requests, and of these, 2 are doing concurrent transactions at this moment.
How many JDBC
Connections are active and communicating
with the database?
b. What object manages these connections as a group for the app, optimizing short-term use of JDBC connections? Specifically:
Class name of object:
What code creates this object:
c. How many Session objects are in tomcat’s memory?
d. Is there any worry that the two requests with concurrent transactions for different users of pizza3 will be sharing a PizzaOrder object in memory? Explain.
3. (30) Application Design and Layers. Currently the products in the music project are unchanging. Suppose you have been asked to add an admin capability to change the price of any specific product. This change will make Products mutable, but don’t worry here about those mutable objects being in the presentation layer.
a. Explain why
void changePrice(Product updatedProduct) throws ServiceException
is not a good choice for a new service layer method. Hint: what code would provide the “updatedProduct” object?
b. Show a good choice for the changePrice service method signature.
c. Describe any changes needed to the DAO API for your design, or explain why none are needed.
d. Describe any changes needed to the database schema for your design
e. In your design, is there a new transaction? If so, what does it do?
(30) 4. The Database Model and SQL.
Suppose we want to enhance the music project to allow users to submit votes (or “likes”) for songs, i.e., tracks. A user vote is submitted by a certain registered user for a certain track. A user can’t undo their vote once made, and each user can only vote at most once for each track, that is, additional votes for the same track and user will be just ignored. We also want to record the time the vote was submitted (the one that counted, not discarded duplicate votes). Note the core schema at the end of the exam.
a. Give the create table statement for your new vote table, complete with any appropriate foreign key constraints.
b. Show the new Vote domain class, with references to related domain objects corresponding to any foreign keys you specified above. As usual, you can put “// getters and setters…”
c. Write SQL to find the number of votes each CD has received, that is, summed over all their tracks. List CD product code and number of votes.
d. Write SQL to find users who have voted for a track but never downloaded that track.
(30) 5. Consider the application scenario from the practice midterm. Suppose you are automating operations for a store selling PCs. All PCs of a certain model number are equivalent as far as buyers are concerned, but the store wants to sell them in FIFO (first-in, first-out) order so that no box gets too worn-looking. Each PC has a model number (int), serial number (10-char string), vendor id (int), and delivery date (int day number, when the PC arrived at the store.) At sale-time, the salesperson will enter a model number and get back the serial number of the system to sell (in case of ties for oldest, any one of the oldest.)
Basic music project schema (no admin tables)
CREATE TABLE product(