导包
import org.apache.flink.api.common.serialization.SimpleStringSchema
import org.apache.flink.configuration.Configuration
import org.apache.flink.streaming.api.functions.sink.{RichSinkFunction, SinkFunction}
import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer
import org.apache.flink.streaming.api.scala._
import java.sql.{Connection, DriverManager, PreparedStatement}
import java.util.Properties
样例类
case class SensorReading(id:String,timestamp:Long,temperature:Double)
scala代码
object jdbcSinkTest {
def main(args: Array[String]): Unit = {
//创建处理流环境
val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
//配置kafka信息
val prop = new Properties()
prop.setProperty("bootstrap.servers","192.1