Java Reference
In-Depth Information
getUser()
method
downcast
deserializeObj()
method
new User
object
FIGURE 11-53
Finally, the requirements document indicates that the program should
return two lists of values. The first case is a list of selected fields for all users that
contains multiple records from a result set. The second case is a list of all stocks
held for a given user. Both cases return multiple records from the result set,
using the ORDER BY clause to sort them. Because the result sets are closed
before either method returns, the data must be saved into structures the meth-
ods can return. Each method iterates through its respective result set and stores
the results into an ArrayList. The ArrayList object then is returned.
The following steps enter the code to create a list of field values from
multiple records and return them in an ArrayList object.
To Obtain a List of Fields from Multiple Database Records
1. Enter lines 365 through 391 as shown in Figure 11-36 on pages 738
and 739.
TextPad displays the listUsers() method (Figure 11-54). The method returns
a list of selected fields sorted by userID for all records from the Users Table.
ArrayList
object
listUsers()
method
SQL ORDER
BY clause
FIGURE 11-54
(continued)
 
Search WWH ::




Custom Search