# Dynamic parameters example

    PreparedStatement ps2 = conn.prepareStatement(
        "UPDATE HotelAvailability SET rooms_available = " +
        "(rooms_available - ?) WHERE hotel_id = ? " +
        "AND booking_date BETWEEN ? AND ?");
    -- this sample code sets the values of dynamic parameters
    -- to be the values of program variables
    ps2.setInt(1, numberRooms);
    ps2.setInt(2, theHotel.hotelId);
    ps2.setDate(3, arrival);
    ps2.setDate(4, departure);
    updateCount = ps2.executeUpdate();

Parent topic: Dynamic parameters
Related reference
Where dynamic parameters are allowed