60-140-046-使用-DataSink-Flink写入到MySQL的2中方式

1.世界

在这里插入图片描述

2.方式一 通过JDBCOutputFormat

​ 在flink中没有现成的用来写入MySQL的sink,但是flink提供了一个类,JDBCOutputFormat,通过这个类,如果你提供了jdbc的driver,则可以当做sink使用。`

JDBCOutputFormat其实是flink的batch api,但也可以用来作为stream的api使用,社区也推荐通过这种方式来进行。

JDBCOutputFormat``用起来很简单,只需要一个prepared statementdriver和database connection`,就可以开始使用了。

 JDBCOutputFormat jdbcOutput = JDBCOutputFormat.buildJDBCOutputFormat()
  

猜你喜欢

转载自blog.csdn.net/qq_21383435/article/details/105277010