while (iterator.hasNext()) {
Subscription subscription = (Subscription) iterator.next();
long destinationId = _destinations.getId(
subscription.getDestination());
if (destinationId == -1) {
throw new PersistenceException(
"Destination identifier not found for destination="
+ subscription.getDestination().getName());
}
PreparedStatement insert = null;
try {
insert = _connection.prepareStatement(
"insert into " + SUBSCRIPTION_TABLE + " values (?, ?)");
insert.setLong(1, consumerId);
insert.setLong(2, destinationId);
insert.executeUpdate();
} catch (SQLException exception) {
throw new PersistenceException("Failed to insert subscription",
exception);
} finally {
SQLHelper.close(insert);
}