1.mysql连接
//t1只有一列a int型
TypeInformation[] fieldTypes =new TypeInformation[]{
BasicTypeInfo.INT_TYPE_INFO
};
RowTypeInfo rowTypeInfo =new RowTypeInfo(fieldTypes);
JDBCInputFormat jdbcInputFormat = JDBCInputFormat.buildJDBCInputFormat()
.setDrivername("com.mysql.jdbc.Driver")
.setDBUrl("jdbc:mysql://localhost/test1")
.setUsername("root")
.setPassword("123456")
.setQuery("select * from t1")
.setRowTypeInfo(rowTypeInfo)
.finish();
2.flink sql
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSource s = env.createInput(jdbcInputFormat); //datasource
BatchTableEnvironment tableEnv =new BatchTableEnvironment(env, TableConfig.DEFAULT());
tableEnv.registerDataSet("t2", s, "a");</