... 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

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.