RH2:连接到R中的H2数据库 [英] RH2: Connect to H2 Database in R
问题描述
我尝试将RH2连接到H2(1.4.181)数据库.我尝试了不同的操作,例如重新安装R,并在Ubuntu上修复了rJava的潜在问题.但是以下错误不会消失:
I tried to connect with RH2 to a H2 (1.4.181) Database. I've tried different things, like reinstalling R, and fixing potential problems with rJava on Ubuntu. However following error does not disappear:
> library("RH2")
Loading required package: chron
Loading required package: RJDBC
Loading required package: DBI
Loading required package: rJava
> con <- dbConnect(H2(driverClass="org.h2.Driver", jars = "~/h2-1.4.181.jar"), "jdbc:h2:~/test", "sa", "")
Error in is(object, Cl): error in evaluating the argument 'drv' in selecting a method for function 'dbConnect': Error in .jfindClass(as.character(driverClass)[1]) : class not found
有人知道如何解决这个问题,还是我在语法上犯了一个错误?
Does anyone know how to solve this or did I make a mistake in the syntax?
推荐答案
我认为jars
参数已损坏.我的猜测是它不是在前面.
I think the jars
argument is broken. My guess is that it isn't pre-pending.
我通过在更新的软件包库中替换了旧的H2 jar包(在Mac OS X上)对其进行了修复.具体来说:
I fixed it (on Mac OS X) by replacing the old H2 jar in my package library with an updated one. Specifically:
box:java nmvanhoudnos$ pwd
/Users/nmvanhoudnos/Library/R/3.2/library/RH2/java
box:java nmvanhoudnos$ ls
h2-1.3.175.jar
box:java nmvanhoudnos$ mv h2-1.3.175.jar h2-1.3.175.old
box:java nmvanhoudnos$ cp ~/workspace/defectprediction/h2*.jar .
box:java nmvanhoudnos$ ls
h2-1.3.175.old h2-1.4.184.jar
您将需要在其中针对操作系统,文件系统和更新H2 jar的位置进行适当的更改.
Where you will need to make the appropriate changes for your OS, filesystem, and location of the update H2 jar.
一旦有了新的jar文件,就可以测试它在R中的工作方式,如下所示:
Once you have the new jar file in place, you can test that it works in R as follows:
> library(RH2)
> con <- dbConnect(H2())
> s <- "select VALUE from INFORMATION_SCHEMA.SETTINGS where NAME = 'info.VERSION'"
> dbGetQuery(con, s)
VALUE
1 1.4.184 (2014-12-19)
符合预期.
这篇关于RH2:连接到R中的H2数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!