PySpark发现JDBC没有合适的驱动程序的:mysql:// DBHOST [英] PySpark No suitable driver found for jdbc:mysql://dbhost
问题描述
我想我的数据框写入到一个MySQL表。我越来越没有合适的驱动程序找到了JDBC:MySQL的:当我尝试写// DBHOST
。
I am trying to write my dataframe to a mysql table. I am getting No suitable driver found for jdbc:mysql://dbhost
when I try write.
由于preprocessing我从在同一数据库其他表读取并没有问题这样做的一部分。我能做到的全力奔跑和行保存到一个文件拼花所以它肯定是从MySQL数据库读取。
As part of the preprocessing I read from other tables in the same DB and have no issues doing that. I can do the full run and save the rows to a parquet file so it is definitely reading from the mysql DB.
我使用的提交:
火花提交--conf spark.executor.extraClassPath = / home / user中/下载/使用mysql-connector-java的5.1.35-bin.jar --driver级,路径为/ home /user/Downloads/mysql-connector-java-5.1.35-bin.jar --jars /home/user/Downloads/mysql-connector-java-5.1.35-bin.jar main.py
和我使用的写:
df.write.jdbc(URL =的jdbc:mysql的:// DBHOST / DBNAME,表=表名,模式=追加,属性= {用户:DBUSER ,密码:s3cret})
推荐答案
这是相关的类加载器的错误。这是票呢: https://issues.apache.org/jira/browse/ SPARK-8463 ,这是它的拉力要求: https://github.com /阿帕奇/火花/拉/ 6900 。
This is a bug related the the classloader. This is the ticket for it: https://issues.apache.org/jira/browse/SPARK-8463 and this is the pull request for it: https://github.com/apache/spark/pull/6900.
一个解决方法是使用mysql-connector-java的5.1.35-bin.jar在同一个位置复制到每一台机器,因为它是驱动程序。
A workaround is to copy mysql-connector-java-5.1.35-bin.jar to every machine at the same location as it is on the driver.
这篇关于PySpark发现JDBC没有合适的驱动程序的:mysql:// DBHOST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!