CS636 Midterm Exam, for practice, S21   NAME:_________________________                            

Open books, handouts, solutions, browser use, etc., but not conversations with others. Note there is no SQL problem on this practice exam, but there will be SQL queries on the real exam. Points are marked in parentheses.  Total points = 100.

1.       (24) 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.) 

  1. Using our client-server database applications technology, how should we hold the data on all the PCs to support this application?  Write the SQL that the program needs to use to create an empty version of the data holder. 

 

 

 


  1. Given a model number, say 1234, for the next PC to sell, write the SQL query that determines the serial number of the PC that should be selected for the customer.
  2.  

     

     

  3. Design a domain class and DAO API (method signatures only) for this app that supports insert as well as the retrieval as described above.

 

 

 

2.       (14) In the same scenario as problem 1, once a PC is sold, we need to keep track of the customer for each individual PC.  Each PC has a unique customer but a single customer can purchase multiple PCs. Each customer has a string name and a customer id, custid (a unique integer).

  1. How should we hold the data on customers?  As in 1a, show the creation of the data holder using SQL.

 

 

  1. How do we specify the customer for each PC?
  2.  

     

  3. What foreign key constraint can be added to this system to improve its integrity?

 

 

3.  (24) Web Background

  1. Write two simple web pages (i.e., provide the HTML code for) a.html and b.html that reside in the same directory with local path /testmsg on a certain web server.  Page a links to page b, and page b has a form with a single text input with name “msg”, no ACTION specified, but with a submit button that POSTs the form to the server.. 

 

 

 

 

 

 

  1. Suppose a user browses to page a.html as served by the web server, follows the link to b.html, and then fills in “hello” in the text box and clicks the submit button.  Give the sequence of HTTP request and responses (first line of request and any body it has, content of response) to this web server that would happen, stopping after the request that carries the “hello” data back to the server (using b.html’s local path, the default ACTION URI.) Here a.html and b.html have no images or CSS files.

 

 

 


 

4.  (14) Maven and command line tools.

a.  Consider two copies of the same Maven project, in top-level directories dir1 and dir2. After "mvn package" has been executed in the first copy, "mvn package" executes for the second copy without any downloads of jar files. Explain why.



b. Suppose a Maven project has one JUnit test that fails, but the main sources are fine (the problem is only in the unit test). What will happen when "mvn package" is executed?  Will this command succeed? Explain why or why not.



c.  Consider JdbcCheckup.java. Suppose your current directory is your own jdbc directory on pe07 containing JdbcCheckup.java and the driver jar files, previously copied from /data/htdocs/cs636/jdbc. Give the command to compile JdbcCheckup.java, and then the command to run it to connect to Oracle on dbs3. You don't need to show how to enter information into the running program.

 

 

5.    (24) System implementation.  In pizza1 consider the service method listed here:

     // return all orders for this room, for today, in order by id
    public List<PizzaOrderData> getOrderStatus(int roomNumber) throws ServiceException {
        List<PizzaOrder> pizzaOrders = null;
        List<PizzaOrderData> pizzaOrders1 = new ArrayList<PizzaOrderData>();
        try {
            pizzaOrders = pizzaOrderDAO.findOrdersByRoom(roomNumber, adminDAO.findCurrentDay());    
            for (PizzaOrder order: pizzaOrders) {
                pizzaOrders1.add(new PizzaOrderData(order));
            }    
        } catch (SQLException e) {
            throw new ServiceException("Error in getting status" + e, e);
        }
        return pizzaOrders1;
    }

  1. What calls into the DAO layer occur during the execution of this method?  List their method names in execution order.
  2.  

  3. Explain why this method does not qualify as a POJO “getter”, even though its name starts with “get”.
  4.  

  5. How do we know that there is no UI (user interface action) during the execution of this call?
  6.  

  7. In this code, what call takes a PizzaOrder object and returns the corresponding PizzaOrderData object?

  8. What kind of code (what layer) calls this getOrderStatus method?   
  9.  

  10. This code has a "new" operation (new PizzaOrderData(...)). We are now sensitized to seeing "new" in method code, worrying about DI (dependency injection, discussed in class of Feb. 17) concerns. Is this a case of a new that causes an object dependency (a case where object A has a field that refs object B)? Explain.