背景:能看到这篇博客的伙计儿,应该是充分理解了[理想是丰满的 现实是骨感] 这句名言了吧。
为啥子这么说呢,那就是 不就是个SparkSql从hive导入到mysql吗!
有什么技术含量,但是呢 不断地踩坑ing填坑ing。
废话不多说,直接上硬菜。
package com.test
import java.sql.{Connection, DriverManager, PreparedStatement}
import java.text.{DateFormat, SimpleDateFormat}
import java.util.{Calendar, Properties}
import org.apache.spark.rdd.{JdbcRDD, RDD}
import org.apache.spark.sql.{Row, SQLContext, SaveMode}
import org.apache.spark.sql.hive.HiveContext
import org.apache.spark.sql.types._
import org.apache.spark.{SparkConf, SparkContext}
object hiveToMysql {
def main(args: Array[String]) {
var list: List[String] = List[String]()
//初始化SparkContext
val conf = new SparkConf().setAppName("hiveToMysql")
val sc: SparkContext = new SparkContext(conf)
val hc=new HiveContext(sc)
val scoreRdd = new JdbcRDD(sc, () => {
Class.forName("com.mysql.jdbc.Driver").newInstance()
DriverManager.getConne

最低0.47元/天 解锁文章
1274

被折叠的 条评论
为什么被折叠?



