Tag: RJDBC

Connecting R to Oracle Database

No Comments

The following three packages are required to connect to Oracle Database:

  1. DBI
  2. rJava
  3. RJDBC
    The  next steps:
    1. Need appropriate Oracle JDBC Drivers compatible with the Java version you like to support.
    2. To connect to the source database you need the following: Hostname or IP, Port, Service name or SID, Username, Password
    3. Use the information from Number 2 to construct a Data Source Name or DSN in the format:

    jdbc:oracle:thin:@hostname:port:sid

    Now, execute the following steps to connect to the database:
                                       

library(RJDBC)
# Create connection driver
jdbcDriver = JDBC(driverClass="oracle.jdbc.OracleDriver",
classPath="lib/classes12.jar")

#Open connection
jdbcConn = dbConnect(jdbcDriver,"jdbc:oracle:thin:@database.hostname.com:port:sid",
"username","password")

#Close connection
dbDisconnect(jdbcConn)
Categories: Data Sources Tags: Tags: , ,