Spark Unable to find JDBC Driver

前端 未结 10 2216
栀梦
栀梦 2020-11-28 08:47

So I\'ve been using sbt with assembly to package all my dependencies into a single jar for my spark jobs. I\'ve got several jobs where I was using c3p0 to setu

10条回答
  •  佛祖请我去吃肉
    2020-11-28 09:32

    This person was having similar issue: http://apache-spark-user-list.1001560.n3.nabble.com/How-to-use-DataFrame-with-MySQL-td22178.html

    Have you updated your connector drivers to the most recent version? Also did you specify the driver class when you called load()?

    Map options = new HashMap();
    options.put("url", "jdbc:mysql://localhost:3306/video_rcmd?user=root&password=123456");
    options.put("dbtable", "video");
    options.put("driver", "com.mysql.cj.jdbc.Driver"); //here
    DataFrame jdbcDF = sqlContext.load("jdbc", options); 
    

    In spark/conf/spark-defaults.conf, you can also set spark.driver.extraClassPath and spark.executor.extraClassPath to the path of your MySql driver .jar

提交回复
热议问题