Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import java.util._
  2.  
  3. //Create a Property object as below. The class is part of java.util
  4. val jdbc_connection = new Properties()
  5.  
  6. //The driver specified below you have to add from sbt repository by including below statement in your build.sbt file
  7. //libraryDependencies += "mysql" % "mysql-connector-java" % "8.0.17"
  8. jdbc_connection.add("driver", "com.mysql.jdbc.Driver")
  9. jdbc_connection.add("user", "root")
  10. jdbc_connection.add("password", "password")
  11.  
  12. //Create the DataFrame
  13. val ordersDF = spark.read.format("csv").
  14. //Below statement inserts the details in the DataFrame ordersDF into the table "orders"
  15. ordersDF.write.mode("append").jdbc("jdbc:mysql://localhost/retail_db", "orders", jdbc_connection)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement