Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- spark
- .read
- .format("jdbc")
- .option("url", "jdbc:mysql://localhost:3306/mydb")
- .option("driver", "com.mysql.jdbc.Driver")
- .option("dbtable", "mydb")
- .option("user", "root")
- .option("password", "")
- .load()
- val spark = SparkSession.builder().appName("MyApp").master("local[*]").getOrCreate()
- val loadedData=spark
- .read
- .format("jdbc")
- .option("url", "jdbc:mysql://localhost:3306/mydatabase")
- .option("driver", "com.mysql.jdbc.Driver")
- .option("mytable", "mydatabase")
- .option("user", "root")
- .option("password", "toor")
- .load().createOrReplaceTempView("mytable")
- val dataFrame=spark.sql("Select * from mytable")
- dataFrame.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement