Dear Learner,

Greetings!

Please find below details.

spark2-shell --jars mysql-connector-java-5.1.42-bin.jar
 
Please find below code.

val sqlContext = new org.apache.spark.sql.SQLContext(sc)
val dataframe_mysql = sqlContext.read.format("jdbc").option("url", "jdbc:mysql://mysqldb.edu.cloudlab.com/userdb_nilesh").option("driver", "com.mysql.jdbc.Driver").option("dbtable", "dept").option("user", "labuser").option("password", "edureka").load() 

dataframe_mysql.show


(Please ignore the post output error)

image

Please try and let us know if you face any issue.

We are eagerly waiting for your response.