June 2017
Beginner
1296 pages
69h 23m
English
... the results of the query
SELECT number FROM seats WHERE (taken = 0) AND (type = type) AND (class = class)
The parameters type and class in the query are replaced with values of method reserve’s seatType and classType parameters.
If resultSet is not empty (i.e., at least one seat is available that matches the selected criteria), the condition in line 53 is true and the web service reserves the first matching seat number. Recall that ResultSet method next returns true if a nonempty row exists, and positions the cursor on that row. We obtain the seat number (line 55) by accessing resultSet’s first column (i.e., resultSet.getInt(1)—the first column in the row). Then lines 56–59 configure a PreparedStatement and execute the SQL:
UPDATE seats SET
Read now
Unlock full access