RJDBC-首次执行脚本时出现ClassNotFoundException

时间:2019-06-25 09:43:34

标签: r rjdbc

我有一个密码

    library(RJDBC)
    library(DBI)
    library(rJava)
    .jinit()
    .jclassLoader()$setDebug(1L)
      print(.jclassPath())
    jdbcDriver <- JDBC(driverClass = "oracle.jdbc.OracleDriver", 
            classPath = "patTo/ojdbc6.jar")

但是当我第一次在R控制台中执行它时,我得到了多个ClassNotFoundException。

RJavaClassLoader@1540e19d.findClass(oracle.as.jmx.framework.PortableMBeanFactory)
 - URL loader did not find it: java.lang.ClassNotFoundException: oracle.as.jmx.framework.PortableMBeanFactory
RJavaClassLoader.findClass("oracle.as.jmx.framework.PortableMBeanFactory")
 - trying class path "/usr/local/lib/R/site-library/rJava/java"
   Directory, can get '/usr/local/lib/R/site-library/rJava/java/oracle/as/jmx/framework/PortableMBeanFactory.class'? NO
 - trying class path "/etc/jdbc/ojdbc6.jar"
   JAR file, can get 'oracle/as/jmx/framework/PortableMBeanFactory'? NO
 - trying class path "/usr/local/lib/R/site-library/RJDBC/java/RJDBC.jar"
   JAR file, can get 'oracle/as/jmx/framework/PortableMBeanFactory'? NO
    >> ClassNotFoundException 
RJavaClassLoader@1540e19d.findClass(oracle.jdbc.driver.OracleDiagnosabilityMBean)
RJavaClassLoader@1540e19d.findClass(oracle.jdbc.driver.DiagnosabilityMXBean)

但是,如果我第二次运行完全相同的代码,它可以正常工作,并且不会引发蚂蚁异常。

也许听起来很怪异,但是看起来将驱动程序加载到类路径上需要花费一些时间,这就是为什么第二轮运行良好,而第一轮却无法运行的原因。

有什么建议吗?

0 个答案:

没有答案