spark 读取jdbc mysql

1.加mysql jar

spark-shell --master local[2] --jars /Users/walle/app/mysql-connector-java-8.0.11.jar

2. 连接jdbc

val mysqlDF = spark.read.format("jdbc").option("url", "jdbc:mysql://localhost:3306").option("dbtable", "baidusong.gedan").option("user", "root").option("password", "root").option("driver", "com.mysql.jdbc.Driver").load()
mysqlDF.show()

http://www.waitingfy.com/archives/4362

4362

Leave a Reply

Name and Email Address are required fields.
Your email will not be published or shared with third parties.