线程“主”中的异常java.sql.SQLException:运行spark-submit时没有合适的驱动程序

时间:2018-07-20 06:55:38

标签: apache-spark apache-spark-2.0 spark-submit

火花版本:2.3.0

我正在运行带有--jars选项的 spark-submit 命令。

我已经在命令中提供了 ojdbc6.jar ,如下所示。

命令

./spark-submit --class com.sample.ABC --jars /scratch/user/abc/drools-jars/ojdbc6.jar --master spark://IP:Port "/scratch/user/abc/POC jar/ABC-0.0.1-SNAPSHOT.jar"

尽管如此,我还是得到了例外:

Exception in thread "main" java.sql.SQLException: No suitable driver
        at java.sql.DriverManager.getDriver(DriverManager.java:315)
        at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions$$anonfun$7.apply(JDBCOptions.scala:85)
        at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions$$anonfun$7.apply(JDBCOptions.scala:85)
        at scala.Option.getOrElse(Option.scala:121)
        at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions.<init>(JDBCOptions.scala:84)
        at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions.<init>(JDBCOptions.scala:35)
        at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:34)
        at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:340)
        at org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:239)
        at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:227)
        at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:164)
        at com.sample.Transformation.main(Transformation.java:76)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
        at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:879)
        at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:197)
        at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:227)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:136)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

1 个答案:

答案 0 :(得分:1)

--driver-class-path添加到命令中,如下所示:

./spark-submit --class com.sample.ABC --jars /scratch/user/abc/drools-jars/ojdbc6.jar `--driver-class-path /scratch/user/abc/drools-jars/ojdbc6.jar --master spark://IP:Port "/scratch/user/abc/POC jar/ABC-0.0.1-SNAPSHOT.jar"

这解决了问题。