开发者社区> 问答> 正文

使用flink-jdbc-driver写入mysql时失败(flink1.10.0)

意图:通过jdbc访问gateway,做一个mysql表写入的测试。通过jdbc-driver创建mysql表成功,但执行写入数据时失败。SQL-gateway采用默认配置。但语句直接在sqlclient中执行可以成功。想请教一下,是定义不正确?还是环境配置不正确。正常来说不是应该默认使用tablesink吗?错误提示如下:Caused by: org.apache.flink.table.api.TableException: RetractStreamTableSink and UpsertStreamTableSink is not supported in Batch environment. at org.apache.flink.table.planner.plan.nodes.physical.batch.BatchExecSink.translateToPlanInternal(BatchExecSink.scala:85) at org.apache.flink.table.planner.plan.nodes.physical.batch.BatchExecSink.translateToPlanInternal(BatchExecSink.scala:48) at org.apache.flink.table.planner.plan.nodes.exec.ExecNode$class.translateToPlan(ExecNode.scala:58) at org.apache.flink.table.planner.plan.nodes.physical.batch.BatchExecSink.translateToPlan(BatchExecSink.scala:48) at org.apache.flink.table.planner.delegation.BatchPlanner$$anonfun$translateToPlan$1.apply(BatchPlanner.scala:69) at org.apache.flink.table.planner.delegation.BatchPlanner$$anonfun$translateToPlan$1.apply(BatchPlanner.scala:68)

源代码如下:Connection connection = DriverManager.getConnection("jdbc:flink://dataflow1:8083?planner=blink");

Statement statement = connection.createStatement();

sql = "CREATE TABLE t_user_target (\n" +

" id BIGINT,\n" +

" username VARCHAR\n" +

") WITH (\n" +

" 'connector.type' = 'jdbc',\n" +

" 'connector.driver' = 'com.mysql.jdbc.Driver',\n" +

" 'connector.url' = 'jdbc:mysql://172.18.100.85:3306/targetdb',\n" +

" 'connector.table' = 't1target',\n" +

" 'connector.username' = 'root',\n" +

" 'connector.password' = 'root',\n" +

" 'connector.write.flush.max-rows' = '5000'\n" +

");";

statement.executeUpdate(sql);

statement.execute("insert into t_user_target values(1,'fan'),(2,'ss')");*来自志愿者整理的flink邮件归档

展开
收起
船长的小螺号 2021-12-03 10:23:46 1218 0
1 条回答
写回答
取消 提交回答
  • 当前 batch 模式还不支持 UpsertTableSink,不过已经有 PR 在支持中了: https://issues.apache.org/jira/browse/FLINK-15579*来自志愿者整理的FLINK邮件归档

    2021-12-03 10:50:32
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
搭建电商项目架构连接MySQL 立即下载
搭建4层电商项目架构,实战连接MySQL 立即下载
PolarDB MySQL引擎重磅功能及产品能力盛大发布 立即下载

相关镜像