Java Reference
In-Depth Information
The process consists of a few basic steps:
Describe how the data will be retrieved and displayed.
1
Determine which database structures are involved.
2
Write out the SQL in static form.
3
Apply Dynamic SQL tags to static SQL .
4
This is a pretty simple page but, as you know, there is always more behind it than
meets the eye. So in the following sections, we'll look at the code to make this work.
8.3.1
Defining how to retrieve and display data
On each page of the JGameStore application we want to implement a simple
search field with a search button. The search field will tokenize terms by spaces.
For example, if we enter Adventure Deus the two terms will be Adventure and
Deus . Each term should check for an inclusive match against the product's cate-
goryId , name, and description. Once the search button is clicked, any resulting
products should be paged in increments of four.
8.3.2
Determining which database structures are involved
Let's move on to defining which table structures are involved.
Since we are only searching against the categoryId , name,
and description, we will require only the Product table to ful-
fill our requirements (figure 8.3). The Product table contains
all of the individual product information that we will need
for search and display.
8.3.3
Writing the SQL in static format
For starters we will construct some static SQL that will select
all the necessary fields we will need to display in our search
results. Listing 8.8 shows the static query we have assembled
to accomplish the display of product information.
Figure 8.3 Diagram
of the table involved
in the simple product
query
Listing 8.8
Static SQL mock-up
SELECT
PRODUCTID,
NAME,
DESCRIPTION,
IMAGE,
CATEGORYID
FROM PRODUCT
Search WWH ::




Custom Search