flink通过JDBC连接MySQL

StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);

DataStreamSource input = env.createInput(JDBCInputFormat.buildJDBCInputFormat()
        .setDrivername("com.mysql.cj.jdbc.Driver")
        .setDBUrl("jdbc:mysql://114.115.150.**:3306/?serverTimezone=UTC")
        .setUsername("dazhihui")
        .setPassword("dazhihui")
        .setQuery("select id from dazhihui.tq_ar_party limit 1")
        .setRowTypeInfo(new RowTypeInfo(BasicTypeInfo.INT_TYPE_INFO))
        .finish()
);
Table table = tableEnv.fromChangelogStream(input);
table.execute().print();

你可能感兴趣的:(java,flink,mysql)