pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 调用 o23.load 时发生错误 没有合适的驱动程序)
问题描述
我在 Mac 上使用 docker image sequenceiq/spark 来研究这些spark examples,在学习过程中,我根据这个答案,当我启动Simple Data Operations
例子,这里是发生了什么:
I use docker image sequenceiq/spark on my Mac to study these spark examples, during the study process, I upgrade the spark inside that image to 1.6.1 according to this answer, and the error occurred when I start the Simple Data Operations
example, here is what happened:
当我运行 df = sqlContext.read.format("jdbc").option("url",url).option("dbtable","people").load()
它引发错误,与pyspark控制台的完整堆栈如下:
when I run df = sqlContext.read.format("jdbc").option("url",url).option("dbtable","people").load()
it raise a error, and the full stack with the pyspark console is as followed:
这是我迄今为止尝试过的:
Here is what I have tried till now:
下载
mysql-connector-java-5.0.8-bin.jar
,放入/usr/local/spark/lib/
.还是一样的错误.
Download
mysql-connector-java-5.0.8-bin.jar
, and put it in to/usr/local/spark/lib/
. It still the same error.
像这样创建t.py
:
然后,我尝试了 spark-submit --conf spark.executor.extraClassPath=mysql-connector-java-5.0.8-bin.jar --driver-class-path mysql-connector-java-5.0.8-bin.jar --jars mysql-connector-java-5.0.8-bin.jar --master local[4] t.py
.结果还是一样.
then, I tried spark-submit --conf spark.executor.extraClassPath=mysql-connector-java-5.0.8-bin.jar --driver-class-path mysql-connector-java-5.0.8-bin.jar --jars mysql-connector-java-5.0.8-bin.jar --master local[4] t.py
. The result is still the same.
- 然后我尝试了
pyspark --conf spark.executor.extraClassPath=mysql-connector-java-5.0.8-bin.jar --driver-class-path mysql-connector-java-5.0.8-bin.jar --jars mysql-connector-java-5.0.8-bin.jar --master local[4] t.py
,有和没有下面的t.py
,还是一样.
- Then I tried
pyspark --conf spark.executor.extraClassPath=mysql-connector-java-5.0.8-bin.jar --driver-class-path mysql-connector-java-5.0.8-bin.jar --jars mysql-connector-java-5.0.8-bin.jar --master local[4] t.py
, both with and without the followingt.py
, still the same.
在此期间,mysql 正在运行.这是我的操作系统信息:
During all of this, the mysql is running. And here is my os info:
hadoop 版本是 2.6.
And the hadoop version is 2.6.
现在不知道下一步该去哪里,希望有大神帮忙指点一下,谢谢!
Now I don't where to go next, so I hope some one can help give some advice, thanks!
推荐答案
当我尝试将脚本写入 MySQL 时,我遇到了java.sql.SQLException:没有合适的驱动程序".
I ran into "java.sql.SQLException: No suitable driver" when I tried to have my script write to MySQL.
这是我为解决这个问题所做的.
Here's what I did to fix that.
在 script.py 中
In script.py
然后我以这种方式运行 spark-submit
Then I ran spark-submit this way
请注意,SPARK_HOME 特定于安装 spark 的位置.对于您的环境,这个 https://github.com/sequenceiq/docker-spark/blob/master/README.md 可能会有所帮助.
Note that SPARK_HOME is specific to where spark is installed. For your environment this https://github.com/sequenceiq/docker-spark/blob/master/README.md might help.
如果以上所有内容都令人困惑,请尝试以下操作:
在 t.py 中替换
In case all the above is confusing, try this:
In t.py replace
与
然后运行
这篇关于pyspark mysql jdbc load 调用 o23.load 时发生错误 没有合适的驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!