object CustomSource {
def main(args: Array[String]): Unit = {
val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
val stringDataStream: DataStream[Provience] = env.addSource(new MySQLSource())
stringDataStream.print("Provience Record")
env.execute
}
}
class MySQLSource() extends RichSourceFunction[Provience] {
var ps: PreparedStatement = _
var connection: Connection = _
var resultSet: ResultSet = _
override def open(parameters: Configuration): Unit = {
super.open(parameters)
val driver = "com.mysql.jdbc.Driver"
val url = "jdbc:mysql://hadoop100:3306/test?useSSL=true"
val username = "root"
val password = "123456"
Class.forName(driver)
try {
connection = DriverManager.getConnection(url, username, password)
val sql = "select * from DMPProvince;"
ps = connecti