@Internal public class JdbcOutputFormat<In,JdbcIn,JdbcExec extends JdbcBatchStatementExecutor<JdbcIn>> extends org.apache.flink.api.common.io.RichOutputFormat<In> implements Flushable, org.apache.flink.api.java.typeutils.InputTypeConfigurable
| Modifier and Type | Class and Description |
|---|---|
static class |
JdbcOutputFormat.Builder
Builder for a
JdbcOutputFormat. |
static interface |
JdbcOutputFormat.RecordExtractor<F,T>
An interface to extract a value from given argument.
|
static interface |
JdbcOutputFormat.StatementExecutorFactory<T extends JdbcBatchStatementExecutor<?>>
A factory for creating
JdbcBatchStatementExecutor instance. |
| Modifier and Type | Field and Description |
|---|---|
protected JdbcConnectionProvider |
connectionProvider |
| Constructor and Description |
|---|
JdbcOutputFormat(JdbcConnectionProvider connectionProvider,
JdbcExecutionOptions executionOptions,
JdbcOutputFormat.StatementExecutorFactory<JdbcExec> statementExecutorFactory,
JdbcOutputFormat.RecordExtractor<In,JdbcIn> recordExtractor) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addToBatch(In original,
JdbcIn extracted) |
protected void |
attemptFlush() |
static JdbcOutputFormat.Builder |
builder() |
void |
close()
Executes prepared statement and closes all resources of this instance.
|
void |
configure(org.apache.flink.configuration.Configuration parameters) |
void |
flush() |
Connection |
getConnection() |
JdbcExecutionOptions |
getExecutionOptions()
Returns configured
JdbcExecutionOptions. |
void |
open(int taskNumber,
int numTasks)
Connects to the target database and initializes the prepared statement.
|
void |
setInputType(org.apache.flink.api.common.typeinfo.TypeInformation<?> type,
org.apache.flink.api.common.ExecutionConfig executionConfig) |
void |
updateExecutor(boolean reconnect) |
void |
writeRecord(In record) |
getRuntimeContext, setRuntimeContextprotected final JdbcConnectionProvider connectionProvider
public JdbcOutputFormat(@Nonnull JdbcConnectionProvider connectionProvider, @Nonnull JdbcExecutionOptions executionOptions, @Nonnull JdbcOutputFormat.StatementExecutorFactory<JdbcExec> statementExecutorFactory, @Nonnull JdbcOutputFormat.RecordExtractor<In,JdbcIn> recordExtractor)
public void setInputType(org.apache.flink.api.common.typeinfo.TypeInformation<?> type,
org.apache.flink.api.common.ExecutionConfig executionConfig)
setInputType in interface org.apache.flink.api.java.typeutils.InputTypeConfigurablepublic void configure(org.apache.flink.configuration.Configuration parameters)
configure in interface org.apache.flink.api.common.io.OutputFormat<In>public void open(int taskNumber,
int numTasks)
throws IOException
open in interface org.apache.flink.api.common.io.OutputFormat<In>taskNumber - The number of the parallel instance.IOExceptionpublic final void writeRecord(In record) throws IOException
writeRecord in interface org.apache.flink.api.common.io.OutputFormat<In>IOExceptionprotected void addToBatch(In original, JdbcIn extracted) throws SQLException
SQLExceptionpublic void flush()
throws IOException
flush in interface FlushableIOExceptionprotected void attemptFlush()
throws SQLException
SQLExceptionpublic void close()
close in interface org.apache.flink.api.common.io.OutputFormat<In>public static JdbcOutputFormat.Builder builder()
public void updateExecutor(boolean reconnect)
throws SQLException,
ClassNotFoundException
SQLExceptionClassNotFoundExceptionpublic JdbcExecutionOptions getExecutionOptions()
JdbcExecutionOptions.@VisibleForTesting public Connection getConnection()
Copyright © 2022–2024 The Apache Software Foundation. All rights reserved.