Triamus
Triamus

Reputation: 2505

R Oracle connect via DBI::dbDriver("Oracle") throws error

I try to do a simple connect to an Oracle database via DBI and ROracle package following instructions from R to Oracle Database Connectivity: Use ROracle for both Performance and Scalability.

When I test the connection via Windows7 > ODBC Data Source Administrator (32bit), the connection is successful. It uses the installed Oracle client OraClient11g_home1 which resides in C:\oracle\Client112_32. ORACLE_HOME environment variable is set to C:\oracle\Client112_32.

I am guessing it may be connected to some 32bit/64bit issue? But even after quite some research I did not find any solution. I also tried running the same in R 32bit but fails as well. BTW, the connection via SQL Developer is also successful.

drv <- DBI::dbDriver("Oracle")
#>Error: Couldn't find driver Oracle. Looked in:
#>* global namespace
#>* in package called Oracle
#>* in package called ROracle

Upvotes: 7

Views: 2701

Answers (2)

Alberto Dell&#39;Era
Alberto Dell&#39;Era

Reputation: 31

Building on user11227405 answer: it is actually enough to load ROracle without attaching it on the search path; library() does both instead:

loadNamespace("ROracle")
drv <- DBI::dbDriver("Oracle")

that might be preferred e.g. in packages, where changing the search path should be avoided

Upvotes: 3

user11227405
user11227405

Reputation: 41

I've had this issue as well. I found that loading the ROracle library beforehand fixes the problem.

library("ROracle")
drv <- DBI::dbDriver("Oracle")

I don't know why though.

Upvotes: 4

Related Questions