栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 云计算 > 云平台

Spark报错:ClassNotFoundException: com.mysql.jdbc.Driver和Public Key Retrieval is not allowed

云平台 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Spark报错:ClassNotFoundException: com.mysql.jdbc.Driver和Public Key Retrieval is not allowed

Spark报错:ClassNotFoundException: com.mysql.jdbc.Driver和Public Key Retrieval is not allowed
  • 错误一: ClassNotFoundException: com.mysql.jdbc.Driver
  • 错误一解决方法
  • 错误二:Public Key Retrieval is not allowed
  • 错误二解决方法
  • 错误三:Establishing SSL connection without server's identity verification is not recommended
  • 错误三解决方法

执行下面这条往mysql数据库插入数据的语句,触发了下面两条错误:

data_df.write.jdbc(url,tablename,'append', prop)
错误一: ClassNotFoundException: com.mysql.jdbc.Driver
  • ClassNotFoundException: com.mysql.jdbc.Driver
错误一解决方法
  • 把mysql的jar包mysql-connector-java-5.1.49.jar放到pyspark的jars目录下/site-packages/pyspark/jars
错误二:Public Key Retrieval is not allowed
  • Public Key Retrieval is not allowed
错误二解决方法
  • 配置连接数据库的url时,加上&allowPublicKeyRetrieval=true
  • 代码中既可以加在url后面,也可以加在prop中,如下所示
  • “allowPublicKeyRetrieval”:“true”
prop={"user":user,"password":password,"driver":"com.mysql.jdbc.Driver","allowPublicKeyRetrieval":"true"}
data_df.write.jdbc(url,tablename,'append', prop)
错误三:Establishing SSL connection without server’s identity verification is not recommended
  • Establishing SSL connection without server’s identity verification is not recommended
错误三解决方法
  • url后面加上如下一串参数
  • ?useUnicode=true&characterEncoding=utf-8&useSSL=false
url='jdbc:mysql://10.10.128.146/unified_view_test?useUnicode=true&characterEncoding=utf-8&useSSL=false'

至此,并能够成功往mysql数据库中插入数据

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/895657.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号