Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util._
- //Create a Property object as below. The class is part of java.util
- val jdbc_connection = new Properties()
- //The driver specified below you have to add from sbt repository by including below statement in your build.sbt file
- //libraryDependencies += "mysql" % "mysql-connector-java" % "8.0.17"
- jdbc_connection.add("driver", "com.mysql.jdbc.Driver")
- jdbc_connection.add("user", "root")
- jdbc_connection.add("password", "password")
- //Create the DataFrame
- val ordersDF = spark.read.format("csv").
- //Below statement inserts the details in the DataFrame ordersDF into the table "orders"
- ordersDF.write.mode("append").jdbc("jdbc:mysql://localhost/retail_db", "orders", jdbc_connection)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement