Package org.apache.flink.connector.jdbc
Class JdbcSink
- java.lang.Object
-
- org.apache.flink.connector.jdbc.JdbcSink
-
@PublicEvolving public class JdbcSink extends Object
Facade to create JDBCsinks.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> org.apache.flink.streaming.api.functions.sink.SinkFunction<T>exactlyOnceSink(String sql, JdbcStatementBuilder<T> statementBuilder, JdbcExecutionOptions executionOptions, JdbcExactlyOnceOptions exactlyOnceOptions, org.apache.flink.util.function.SerializableSupplier<XADataSource> dataSourceSupplier)Create JDBC sink which provides exactly-once guarantee.static <T> org.apache.flink.streaming.api.functions.sink.SinkFunction<T>sink(String sql, JdbcStatementBuilder<T> statementBuilder, JdbcConnectionOptions connectionOptions)Create a JDBC sink with the defaultJdbcExecutionOptions.static <T> org.apache.flink.streaming.api.functions.sink.SinkFunction<T>sink(String sql, JdbcStatementBuilder<T> statementBuilder, JdbcExecutionOptions executionOptions, JdbcConnectionOptions connectionOptions)Create a JDBC sink.
-
-
-
Method Detail
-
sink
public static <T> org.apache.flink.streaming.api.functions.sink.SinkFunction<T> sink(String sql, JdbcStatementBuilder<T> statementBuilder, JdbcConnectionOptions connectionOptions)
Create a JDBC sink with the defaultJdbcExecutionOptions.
-
sink
public static <T> org.apache.flink.streaming.api.functions.sink.SinkFunction<T> sink(String sql, JdbcStatementBuilder<T> statementBuilder, JdbcExecutionOptions executionOptions, JdbcConnectionOptions connectionOptions)
Create a JDBC sink.Note: the objects passed to the return sink can be processed in batch and retried. Therefore, objects can not be
reused.- Type Parameters:
T- type of data inStreamRecord.- Parameters:
sql- arbitrary DML query (e.g. insert, update, upsert)statementBuilder- sets parameters onPreparedStatementaccording to the queryexecutionOptions- parameters of execution, such as batch size and maximum retriesconnectionOptions- parameters of connection, such as JDBC URL
-
exactlyOnceSink
public static <T> org.apache.flink.streaming.api.functions.sink.SinkFunction<T> exactlyOnceSink(String sql, JdbcStatementBuilder<T> statementBuilder, JdbcExecutionOptions executionOptions, JdbcExactlyOnceOptions exactlyOnceOptions, org.apache.flink.util.function.SerializableSupplier<XADataSource> dataSourceSupplier)
Create JDBC sink which provides exactly-once guarantee.Note: the objects passed to the return sink can be processed in batch and retried. Therefore, objects can not be
reused.- Type Parameters:
T- type of data inStreamRecord.- Parameters:
sql- arbitrary DML query (e.g. insert, update, upsert)statementBuilder- sets parameters onPreparedStatementaccording to the queryexecutionOptions- parameters of execution, such as batch size and maximum retriesexactlyOnceOptions- exactly-once options. Note: maxRetries setting must be strictly set to 0 for the created sink to work properly and not to produce duplicates. See issue FLINK-22311 for details.dataSourceSupplier- supplies theXADataSource
-
-