r2.foreachPartition {
it =>
val conn= DriverManager.getConnection(url,username,password)
val del = conn.prepareStatement ("INSERT INTO tweets (ID,Text) VALUES (?,?) ")
for (bookTitle <-it)
{
del.setString(1,bookTitle.toString)
del.setString(2,"my input")
del.executeUpdate
}
}
OR
val employees = sqlContext.load("jdbc", Map("url" -> "jdbc:oracle:thin:user/pass@//localhost:1521/single", "dbtable" -> "hr.employees"))
1条答案
按热度按时间hrirmatl1#
您也可以在spark示例中连接到oracle db: