无法通过RJDBC连接到Oracle数据库

时间:2014-11-11 18:52:16

标签: r rjdbc

当我尝试连接到Oracle11G DB时出错。我的输出如下。请指教

>Sys.setenv(JAVA_HOME='C:/Program Files/Java/jdk1.6.0_45')
> options(java.parameters="-Xmx2g")
> library(rJava)
> .jinit()
[1] 0
> print(.jcall("java/lang/System", "S", "getProperty", "java.version"))
[1] "1.6.0_45"
> library(RJDBC)
> # Create connection driver and open connection
> jdbcDriver = JDBC(driverClass="oracle.jdbc.OracleDriver", classPath="pathtofile/ojdbc6.jar")
> jdbcDriver
An object of class "JDBCDriver"
Slot "identifier.quote":
[1] NA

Slot "jdrv":
[1] "Java-Object{oracle.jdbc.OracleDriver@9506dc4}"

> jdbcConnection = dbConnect(jdbcDriver,"jdbc:oracle:thin:@//hostname:port/servicename","username","password")
Error in dbConnect(jdbcDriver, "jdbc:oracle:thin:@//hostname:port/servicename",  : 
  unused arguments (jdbcDriver, "jdbc:oracle:thin:@//hostname:port/servicename", "username","password")

1 个答案:

答案 0 :(得分:0)

我不确定您是否正在寻找答案,但这就是我建立联系的方式:

library(RJDBC)
drv <- JDBC(driverClass="oracle.jdbc.OracleDriver", classPath="pathtothisfile/ojdbc6.jar") 
conn <- dbConnect(drv, "jdbc:oracle:thin:@//Hostname:Port/SID", "username", "password")