flink-user-zh mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "猫猫" <16770...@qq.com>
Subject 使用flink-jdbc-driver写入mysql时失败(flink1.10.0)
Date Tue, 25 Feb 2020 03:13:14 GMT
意图:通过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')");
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message