flink 从mysql读取数据异常

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

flink 从mysql读取数据异常

air23
你好 参考官网 https://ci.apache.org/projects/flink/flink-docs-release-1.12/zh/dev/table/connectors/jdbc.html
这边读取mysql jdbc数据报错Exception in thread "main" org.apache.flink.table.api.TableException: Only insert statement is supported now.


String  a = "-- register a MySQL table 'users' in Flink SQL\n" +
"CREATE TABLE MyUserTable (\n" +
"  id BIGINT\n" +
") WITH (\n" +
"   'connector' = 'jdbc',\n" +
"   'url' = 'jdbc:mysql://***:3306/monitor',\n" +
"   'table-name' = 't1',\n" +
"   'username' = 'root',\n" +
"   'password' = '***'\n" +
") ";

String b ="-- scan data from the JDBC table\n" +
"SELECT id FROM MyUserTable\n";

tEnv.executeSql(a);



请问是不可以从mysql读取数据吗?
Reply | Threaded
Open this post in threaded view
|

回复:flink 从mysql读取数据异常

guoyb
可以读取的,还有内置flink cdc
select得用query方法,看看是不是用错了execute。



---原始邮件---
发件人: "air23"<[hidden email]&gt;
发送时间: 2021年3月30日(周二) 上午10:25
收件人: "user-zh"<[hidden email]&gt;;
主题: flink 从mysql读取数据异常


你好 参考官网 https://ci.apache.org/projects/flink/flink-docs-release-1.12/zh/dev/table/connectors/jdbc.html
这边读取mysql jdbc数据报错Exception in thread "main" org.apache.flink.table.api.TableException: Only insert statement is supported now.


String&nbsp; a = "-- register a MySQL table 'users' in Flink SQL\n" +
"CREATE TABLE MyUserTable (\n" +
"&nbsp; id BIGINT\n" +
") WITH (\n" +
"&nbsp;&nbsp; 'connector' = 'jdbc',\n" +
"&nbsp;&nbsp; 'url' = 'jdbc:mysql://***:3306/monitor',\n" +
"&nbsp;&nbsp; 'table-name' = 't1',\n" +
"&nbsp;&nbsp; 'username' = 'root',\n" +
"&nbsp;&nbsp; 'password' = '***'\n" +
") ";

String b ="-- scan data from the JDBC table\n" +
"SELECT id FROM MyUserTable\n";

tEnv.executeSql(a);



请问是不可以从mysql读取数据吗?
Reply | Threaded
Open this post in threaded view
|

Re:回复:flink 从mysql读取数据异常

air23
这边是想离线读取。不是走实时的
看到异常是 Only insert statement is supported now

















在 2021-03-30 10:31:51,"guoyb" <[hidden email]> 写道:

>可以读取的,还有内置flink cdc
>select得用query方法,看看是不是用错了execute。
>
>
>
>---原始邮件---
>发件人: "air23"<[hidden email]&gt;
>发送时间: 2021年3月30日(周二) 上午10:25
>收件人: "user-zh"<[hidden email]&gt;;
>主题: flink 从mysql读取数据异常
>
>
>你好 参考官网 https://ci.apache.org/projects/flink/flink-docs-release-1.12/zh/dev/table/connectors/jdbc.html
>这边读取mysql jdbc数据报错Exception in thread "main" org.apache.flink.table.api.TableException: Only insert statement is supported now.
>
>
>String&nbsp; a = "-- register a MySQL table 'users' in Flink SQL\n" +
>"CREATE TABLE MyUserTable (\n" +
>"&nbsp; id BIGINT\n" +
>") WITH (\n" +
>"&nbsp;&nbsp; 'connector' = 'jdbc',\n" +
>"&nbsp;&nbsp; 'url' = 'jdbc:mysql://***:3306/monitor',\n" +
>"&nbsp;&nbsp; 'table-name' = 't1',\n" +
>"&nbsp;&nbsp; 'username' = 'root',\n" +
>"&nbsp;&nbsp; 'password' = '***'\n" +
>") ";
>
>String b ="-- scan data from the JDBC table\n" +
>"SELECT id FROM MyUserTable\n";
>
>tEnv.executeSql(a);
>
>
>
>请问是不可以从mysql读取数据吗?
Reply | Threaded
Open this post in threaded view
|

Re: Re:回复:flink 从mysql读取数据异常

LiangbinZhang
Hi,air23
    JDBCTableSource就是batch模式的,不走实时。Flink解析执行计划时内部会去判断。

Best






air23 wrote

> 这边是想离线读取。不是走实时的
> 看到异常是 Only insert statement is supported now
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> 在 2021-03-30 10:31:51,"guoyb" <

> 861277329@

>> 写道:
>>可以读取的,还有内置flink cdc
>>select得用query方法,看看是不是用错了execute。
>>
>>
>>
>>---原始邮件---
>>发件人: "air23"&lt;

> wangfei23_job@

> &amp;gt;
> &gt;发送时间: 2021年3月30日(周二) 上午10:25
>>收件人: "user-zh"&lt;

> user-zh@.apache

> &amp;gt;;
> &gt;主题: flink 从mysql读取数据异常
>>
>>
>>你好 参考官网
https://ci.apache.org/projects/flink/flink-docs-release-1.12/zh/dev/table/connectors/jdbc.html
>>这边读取mysql jdbc数据报错Exception in thread "main"
org.apache.flink.table.api.TableException: Only insert statement is
supported now.

>>
>>
>>String&nbsp; a = "-- register a MySQL table 'users' in Flink SQL\n" +
>>"CREATE TABLE MyUserTable (\n" +
>>"&nbsp; id BIGINT\n" +
>>") WITH (\n" +
>>"&nbsp;&nbsp; 'connector' = 'jdbc',\n" +
>>"&nbsp;&nbsp; 'url' = 'jdbc:mysql://***:3306/monitor',\n" +
>>"&nbsp;&nbsp; 'table-name' = 't1',\n" +
>>"&nbsp;&nbsp; 'username' = 'root',\n" +
>>"&nbsp;&nbsp; 'password' = '***'\n" +
>>") ";
>>
>>String b ="-- scan data from the JDBC table\n" +
>>"SELECT id FROM MyUserTable\n";
>>
>>tEnv.executeSql(a);
>>
>>
>>
>>请问是不可以从mysql读取数据吗?





--
Sent from: http://apache-flink.147419.n8.nabble.com/