R .jfindClass(as.character(driverClass)[1])中的错误:java.lang.ClassNotFoundException

时间:2019-04-22 20:22:53

标签: r amazon-emr rjava rjdbc

尝试在macOS上建立到EMR配置单元实例的R JDBC连接。收到错误:

    Error in .jfindClass(as.character(driverClass)[1]) : 
    java.lang.ClassNotFoundException

这是我到目前为止所拥有的:

    library(DBI)
    library(rJava)
    library(RJDBC)

    jardir <- "/Users/Downloads/jar_files"
    cp <- paste0(jardir,"/",list.files(path = jardir, pattern = 
    ".jar"))


   .jinit(classpath <- cp)

   drv <- RJDBC::JDBC("com.amazon.hive.jdbc.HS1Driver"
        , classPath = 
   list.files("/Users/Downloads/jar_files",pattern="jar$",
   full.names=T),
   identifier.quote="'")

这是Java版本:

    java version "1.8.0_202"
    Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
    Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

和R版本:

    R version 3.5.1 (2018-07-02) -- "Feather Spray"
    Copyright (C) 2018 The R Foundation for Statistical Computing
    Platform: x86_64-apple-darwin15.6.0 (64-bit)

1 个答案:

答案 0 :(得分:0)

这有效。必须从此处下载jar文件:http://awssupportdatasvcs.com/bootstrap-actions/Simba/AmazonHiveJDBC-1.0.9.1060.zip

然后指向它的类路径。

library(DBI)
library(rJava)
library(RJDBC)

jardir <- "/Users/rockboy23/Hive"
cp <- paste0(jardir,"/",list.files(path = jardir, pattern = ".jar"))


.jinit(classpath <- cp)

# downloaded the driver from here: http://awssupportdatasvcs.com/bootstrap- 
# actions/Simba/AmazonHiveJDBC-1.0.9.1060.zip

drv <- RJDBC::JDBC("com.amazon.hive.jdbc41.HS2Driver"
        , classPath = 
list.files("/Users/rockboy23/Hive",pattern="jar$",full.names=T),
        identifier.quote="'")