val url = "jdbc:oracle:thin:@//ip:1521/数据库名称"
val user = "ods"
val password = "oracle"
val driver = "oracle.jdbc.driver.OracleDriver"
val dbmap = Map("url" -> url, "user" -> user, "password" -> password, "driver" -> driver)
val properties = new Properties()
properties.setProperty("url", url)
properties.setProperty("user", user)
properties.setProperty("password", password)
properties.setProperty("driver", driver)
def saveSummary(rowrdd: RDD[Row], sqlContext: SQLContext): Unit = {
//DateTypes.createStructField()
val schema= StructType(List(StructField("mon_th",IntegerType, true)
, StructField("current_date", DateType, true)
, StructField("amount", DoubleType, true)
, StructField("account_code", StringType, true)
, StructField("summary_code", StringType, true)
, StructField("project", StringType, true)
))
val dataFrame=sqlContext.createDataFrame(rowrdd,schema)
dataFrame.show()
dataFrame.write.mode(SaveMode.Append).jdbc(url,"表名",properties)
}