@Override
    public synchronized void close() {
        if (!closed) {
            closed = true;

            if (this.scheduledFuture != null) {
                scheduledFuture.cancel(false);
                this.scheduler.shutdown();
            }

            if (batchCount > 0) {
                try {
                    flush();
                } catch (Exception e) {
                    LOG.warn("Writing records to JDBC failed.", e);
                    throw new RuntimeException("Writing records to JDBC failed.", e);
                }
            }

            try {
                if (null != jdbcExecMap) {
                    jdbcExecMap.forEach((tableIdentifier, jdbcExec) -> {
                        try {
                            jdbcExec.closeStatements();
                        } catch (SQLException e) {
                            LOG.error("jdbcExec executeBatch get err", e);
                        }
                    });
                }
            } catch (Exception e) {
                LOG.warn("Close JDBC writer failed.", e);
            }
        }
        super.close();
        checkFlushException();
    }
Executes prepared statement and closes all resources of this instance.
inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcMultiBatchingOutputFormat.java