1.世界
2.方式一 通过JDBCOutputFormat
在flink中没有现成的用来写入MySQL的sink,但是flink提供了一个类,JDBCOutputFormat
,通过这个类,如果你提供了jdbc的driver
,则可以当做sink使用。`
JDBCOutputFormat
其实是flink的batch api
,但也可以用来作为stream的api使用,社区也推荐通过这种方式来进行。
JDBCOutputFormat``用起来很简单,只需要一个
prepared statement,
driver和database connection`,就可以开始使用了。
JDBCOutputFormat jdbcOutput = JDBCOutputFormat.buildJDBCOutputFormat()