linux 使用odbc和jdbc


#sudo alien -i oracle-instantclient18.3-odbc-18.3.0.0.0-3.x86_64.rpm
#sudo vim /etc/odbc.ini
[Sample DSN]
#Driver=/usr/lib/oracle/18.3/client64/lib/libsqora.so.18.1
Driver=/usr/lib/oracle/18.3/client64/lib/liboracleodbc_sb64.so
DSN = Oracle
ServerName = //192.168.30.12:1521/JZDB1
UserID = *****
Password = *****


Sys.setenv(NLS_LANG="AMERICAN_AMERICA.ZHS16GBK")
library(DBI)
library(tidyverse)
con <- dbConnect(odbc::odbc(), .connection_string = "Driver={Oracle};",
                 timeout = 10,encoding = "GBK")

org <- tbl(con,sql("select * from sys_org")) %>%
  collect()
 
org %>%
  slice(1:5) 
#dbListTables(con, schema = "IPVSDB")


# org %>% select_if(is.character) %>%
#   map_df(~ iconv(.x,from="GBK",to="UTF-8"))
#
# org %>% select_if(is_character) %>%
#   map_df(~as.factor(.x))

org %>% mutate_at(c("JGLB"),~as.numeric(.x))
org %>% mutate(JGLB=as.numeric(JGBM))


Sys.setenv(NLS_LANG="AMERICAN_AMERICA.ZHS16GBK")
library(RJDBC)
drv <- JDBC("oracle.jdbc.OracleDriver",classPath="/usr/lib/oracle/18.3/client64/lib/ojdbc8.jar", " ")
con <- dbConnect(drv, "jdbc:oracle:thin:@192.168.30.12:1521/JZDB1", "*****", "*****")
dbListTables(con, schema = "IPVSDB")
d <- dbGetQuery(con, "select * from sys_org")
#关闭数据库连接
dbDisconnect(con) 

评论

此博客中的热门博文

V2ray websocket(ws)+tls+nginx分流

Rstudio 使用代理