将 这些数据集 存入MySQL中的众多方法 的其中一种
【Dataframe存入MySQL】
//DataFrame 存入 Mysql
//指定URL
val url="jdbc:mysql://localhost:3306/wc"
//指定要存入的表 (不存在会自动创建)
val table="result_pv";
//设置配置文件
val properties = new Properties()
properties.setProperty("user","root")
properties.setProperty("password","123456")
//执行
df.write.mode("append").jdbc(url,table,properties)
【DataStream存入MySQL】
foreachRDD:作用于Dstream中每一个时间间隔的RDD