Using JBDC to read sql file in spark scala collecting Warehouse error

Refresh

April 2019

Views

215 time

1

I am trying to read MySQL file using Spark Scala. Following is the code I tried

val dataframe_mysql = sqlContext.read.format("jdbc")
 .option("url","jdbc:mysql://xx.xx.xx.xx:xx")
 .option("driver", "com.mysql.jdbc.Driver")
 .option("dbtable", "schema.xxxx")
 .option("user", "xxxx").option("password", "xxxxx").load()

but I am collecting Warehouse path error as following:

Warehouse path is 'file:/C:/Users/Owner/eclipse-workspace/stProject/spark-ware‌​house/'. Exception in thread "main" java.lang.NullPointerException at org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.res‌​olveTable(JDBCRDD.sc‌​ala:72) at org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation‌​.(JDBCRelation‌​.scala:113) at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelation‌​Provider.createRelat‌​ion(JdbcRelationProv‌​ider.scala:45) at

0 answers