Order History

You're down to the last piece of functionality—displaying order history. This is the code on the MyAccount page that will let a customer see his past orders and drill down to a detailed view. To start, you need to add a method to Customer.java (shown in Listing 13.10) to get back a vector of orders for display. Luckily, you already wrote the findOrder code when you created Order.java, so you are already a step ahead.

Listing 13.10. Addition to Customer.java
 import com.bfg.product.Order; . . . public Vector getOrderHistory() { Vector orders = new Vector(); DBConnection dbConn = null; try { dbConn = TurbineDB.getConnection(); if (dbConn == null) { cat.error("Can't get database connection"); } PreparedStatement pstmt = dbConn.prepareStatement(sql_bundle.getString("orderHistory")); ...

Get MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.