Java Reference
In-Depth Information
To Obtain a Database Field Value
1. Enter lines 299 through 325 as shown in Figure 11-36 on pages 737
and 738.
TextPad displays the getStockDesc() method (Figure 11-52). The returned
value is the description of a stock record obtained from the ResultSet
getString() method.
getStockDesc()
method
getString()
method
FIGURE 11-52
When given a user ID, the program also should return all of the user fields
as a User object. As was noted earlier, using an asterisk in the SQL SELECT state-
ment as the selected fields causes a return of all fields for the selected record.
This is done in lines 343 and 344 and, again, by matching a single primary key
value, a single record is obtained. Lines 347 through 357 use the result set data to
create a User object. If no result was obtained, the User reference is left as null.
Finally, the User object, or null, is returned to the calling program.
The following step enters the code to obtain all field values from a user
record and return them as a User object.
To Obtain All Database Field Values
1. Enter lines 326 through 364 as shown in Figure 11-36.
TextPad displays the getUser() method (Figure 11-53). The method returns
a User object with data from a user record.
 
Search WWH ::




Custom Search