sql >> Databasteknik >  >> RDS >> Oracle

Ansluter till oracle 10g-databas via R

Nedan är vad jag gjorde för att ansluta R till Oracle-databasen

  1. Ladda ner Oracle-drivrutinen JDK http://www.oracle.com .com/technetwork/java/javase/downloads/index.html
  2. Installera RJDBC

kör sedan koden nedan i r

library(RJDBC)
## Loading required package: DBI
## Loading required package: rJava
# specify the driver type and location in your machine

jdbcDriver = JDBC("oracle.jdbc.OracleDriver",
                  classPath="C:/app/techsupport/product/11.2.0/client_1/jdbc/lib/ojdbc6.jar") # may be different on your machine, it's based on your JDK installation

# connect to the database

conn = dbConnect(jdbcDriver, "jdbc:oracle:thin:@//database.hostname.com:port/service_name",  # get the database name, port, and service name from you DBA
             user = YourUserName,
             password = YourPassword)

# get office table using a query string

startTime <- Sys.time() # start timer
OfficeTable = dbGetQuery(conn, "select * from office")
# disconnect after working with database
dbDisconnect(conn)
## [1] TRUE
Sys.time() - startTime  # calc time to import table
## Time difference of 0.1630161 secs
# take a look at the data
str(OfficeTable)
## 'data.frame':    373 obs. of  22 variables:



  1. RMySQL-systemfel:10060

  2. Infoga en enkel lista i MySQL-tabellen (php)

  3. Entity Framework Core PostgreSQL json-fråga

  4. Hur ställer du in ett standardvärde för en MySQL Datetime-kolumn?