O'Reilly logo

MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL by James Turner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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")); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required