package com.sjw.flink
import org.apache.flink.api.common.typeinfo.BasicTypeInfo
import org.apache.flink.api.java.io.jdbc.JDBCInputFormat
import org.apache.flink.api.java.typeutils.RowTypeInfo
import org.apache.flink.api.scala._
import org.apache.flink.types.Row
object JDBCSourceTest {
def main(args: Array[String]): Unit = {
// //搭建环境
// val env = ExecutionEnvironment.getExecutionEnvironment
// var inputMysq: DataSet[Row] = MyJDBCRead(env)
// inputMysq.map(r => (r.getField(0),r.getField(1))).print()
//
// def MyJDBCRead(env:ExecutionEnvironment): DataSet[Row] ={
//
// var inputMysql: DataSet[Row] = env.createInput(JDBCInputFormat.buildJDBCInputFormat()
// .setDrivername("com.mysql.jdbc.Driver")
// .setDBUrl("jdbc:mysql://sunjunwei1.com:3306/1711F")
// .setUsername("root")
// .setPassword("986262")
// .setQuery("select sensor,temp from temperature")
// .setRowTypeInfo(new RowTypeInfo(BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.DOUBLE_TYPE_INFO))
// .finish()
// )
// inputMysql
// }
}
}