MysqlSink_StructuredStreaming.scala
代码:
package com.hr.utils
import org.apache.spark.sql.ForeachWriter
import java.sql.{Connection, DriverManager, PreparedStatement}
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.functions._
import scala.collection.mutable.ListBuffer
import java.sql.{Connection, DriverManager, PreparedStatement}
import java.text.SimpleDateFormat
import org.apache.spark.{SparkConf, SparkContext, rdd}
import org.apache.spark.sql.Row
import com.hr.utils.DataSourceUtil._
import org.apache.spark
import com.hr.utils.DataSourceUtil.real_jdbcDriver
import com.hr.utils.MysqlSink_all.{getConnection, release}
import org.apache.spark.sql.{ForeachWriter, Row}
import shapeless.record
/**
* HF
* 2020-06-27 4:47
* replaceIntoMysqlTableName :要插入的mysql的表名
* mysqlFieldCount :要插入的mysql的表的字段的个数
*/
class MysqlSink_StructuredStreaming(replaceIntoMysqlTableName: String, mysqlFieldCount: Int