Spark Unable to find JDBC Driver

前端 未结 10 2229
栀梦
栀梦 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:13

    spark.driver.extraClassPath does not work in client-mode:

    Note: In client mode, this config must not be set through the SparkConf directly in your application, because the driver JVM has already started at that point. Instead, please set this through the --driver-class-path command line option or in your default properties file.

    Env variable SPARK_CLASSPATH has been deprecated in Spark 1.0+.

    You should first copy the jdbc driver jars into each executor under the same local filesystem path and then use the following options in you spark-submit:

    --driver-class-path "driver_local_file_system_jdbc_driver1.jar:driver_local_file_system_jdbc_driver2.jar"
    --class "spark.executor.extraClassPath=executors_local_file_system_jdbc_driver1.jar:executors_local_file_system_jdbc_driver2.jar"
    

    For example in case of TeraData you need both terajdbc4.jar and tdgssconfig.jar .

    Alternatively modify compute_classpath.sh on all worker nodes, Spark documentation says:

    The JDBC driver class must be visible to the primordial class loader on the client session and on all executors. This is because Java’s DriverManager class does a security check that results in it ignoring all drivers not visible to the primordial class loader when one goes to open a connection. One convenient way to do this is to modify compute_classpath.sh on all worker nodes to include your driver JARs.

提交回复
热议问题