• 【异常】No suitable driver


    出现的异常是:java.sql.SQLException: No suitable driver。是因为缺少mysql包:

    代码中:
    val alterDs: DataFrame = sparkSession.read.format("jdbc")
    .option("url", url)
    .option("driver","com.mysql.jdbc.Driver")->有mysql驱动
    .option("dbtable", altertable)
    .option("user", user)
    .option("password", password)
    .load()

    提交命令:
    spark-submit
    --name OnLineLogAnalysisTest1
    --class com.importpack.OnLineLogAnalysis
    --master yarn
    --deploy-mode cluster
    --driver-memory 2G
    --executor-memory 2G
    --executor-cores 1
    --num-executors 1
    --packages org.influxdb:influxdb-java:2.5,org.apache.spark:spark-streaming-kafka-0-10_2.11:2.4.2
    --jars /home/hadoop/lib/fastjson-1.2.58.jar,/home/hadoop/lib/mysql-connector-java-5.1.43-bin.jar -------->在executor中加入mysql驱动的包
    --driver-class-path /home/hadoop/lib/fastjson-1.2.58.jar,/home/hadoop/lib/mysql-connector-java-5.1.43-bin.jar ------>在driver中也加入mysql驱动的包
    /home/hadoop/lib/ruozetest-1.0.jar

  • 相关阅读:
    redis集群redis-cloud搭建
    Linux下搭建redis服务器
    mybatis主键返回
    分布式文件系统FastDFS
    mapper映射文件不发布
    dubbo发布和引用服务
    PageHelper分页插件
    F. Cards and Joy
    E. Paint the Tree 树形dp
    D. Sequence Sorting dp
  • 原文地址:https://www.cnblogs.com/huomei/p/12103483.html
Copyright © 2020-2023  润新知