How to Connect R to Oracle?

I need to connect R to oracle and I have been unsuccessful so far. I downloaded two packages: RODBC & RODM.

This is the statement that I've been using:

DB <- odbcDriverConnect("DBIORES1",uid="mhala",pwd="XXXXXXX")

But I get this error:

Error in odbcDriverConnect("DBIORES1", uid = "mhalagan", pwd = "XXXXXXX") : 
  unused argument(s) (uid = "mhalagan", pwd = "XXXXXXX")

What information do I need to be able to connect to an oracle database? Am I using the correct package?

Answers


See the help page for odbcDriverConnect(). odbcDriverConnect() does not accept uid or pwd arguments. You probably meant to use odbcConnect() instead:

odbcConnect(dsn = "DBIORES1", uid = "mhala", pwd = "XXXXXXX")

In addition to the RODBC package, there is the RODM package, which I believe is specifically designed for Oracle databases and is further described here: http://www.oracle.com/technetwork/articles/datawarehouse/saternos-r-161569.html . I do not use Oracle databases, so cannot comment on advantages of the two packages.


I've had success in the past connecting to Oracle databases from R with RJDBC. I found it easier to get going as I just grabbed the connection string that I'd used successfully inside the java based GUI I was using at the time and like magic it "just works"(tm).


Did you install the oracle ODBC client/driver? You will need that if you are going to use the ODBC R package. Go to oracle instant client download get the client for your OS. install them and then proceed to configure the ODBC and test the connection outside of R then install the R and RODBC and test inside R.


RJDBC worked just fine for me. You just need to have Oracle-thin driver jar file and configure the connection like:

> install.packages("RJDBC")
> library(RJDBC)
> drv <- JDBC("oracle.jdbc.driver.OracleDriver","/path/to/driver/com/oracle/oracle-thin/11.2.0.1.0/oracle-thin-11.2.0.1.0.jar”)
> conn <- dbConnect(drv, "jdbc:oracle:thin:@database:port:schema”, “user”, “passwd”)

and then is ready to perform some queries.

JA.


Need Your Help

Hbase 0.92.1 Secondary Index Example

hadoop hbase hdfs

I am working on million Rows and columns in hbase 0.92.1. Now, I want to know how to create secondary index using Co-processor. Give some examples program for this.

Retrieve related data-set on Phalcon

mysql orm phalcon relation

I have two tables. Which I wanted to return not only the parent data "Lists", but including the relationship to "ListTypes". How can I do that?