private ExecutedBatch internalBatchExecute() {
        if (!getBinding().isEmpty()) {
            add();
        }

        beforeTemplating();

        final StatementContext ctx = getContext();

        ParsedSql parsedSql = parseSql();
        String sql = parsedSql.getSql();
        ParsedParameters parsedParameters = parsedSql.getParameters();

        try {
            try {
                stmt = createStatement(sql);

                getContext().addCleanable(() -> cleanupStatement(stmt));
                getConfig(SqlStatements.class).customize(stmt);
            } catch (SQLException e) {
                throw new UnableToCreateStatementException(e, ctx);
            }

            if (bindings.isEmpty()) {
                return new ExecutedBatch(stmt, new int[0]);
            }

            beforeBinding();

            try {
                ArgumentBinder binder = new ArgumentBinder.Prepared(this, parsedParameters, bindings.get(0));
                for (Binding binding : bindings) {
                    ctx.setBinding(binding);
                    binder.bind(binding);
                    stmt.addBatch();
                }
            } catch (SQLException e) {
                throw new UnableToExecuteStatementException("Exception while binding parameters", e, ctx);
            }

            beforeExecution();

            try {
                final int[] modifiedRows = SqlLoggerUtil.wrap(stmt::executeBatch, ctx, getConfig(SqlStatements.class).getSqlLogger());

                afterExecution();

                ctx.setBinding(new PreparedBinding(ctx));

                return new ExecutedBatch(stmt, modifiedRows);
            } catch (SQLException e) {
                throw new UnableToExecuteStatementException(Batch.mungeBatchException(e), ctx);
            }
        } finally {
            bindings.clear();
        }
    }
Executes the batch, returning the result obtained from the given {@link ResultProducer}.

@param <R> the type of the result
@param producer the result producer.
@return value returned by the result producer.
core/src/main/java/org/jdbi/v3/core/statement/PreparedBatch.java