设置drv, host,port, sid(数据库):
1.drv<-dbDriver("Oracle")
2.host<-"192.168.8.85"
3.port<-1521
4.sid<-"orcl"
得到连接字符串:
connect.string<-paste("(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=",host,")(PORT=",port,"))","(CONNECT_DATA=(SID=",sid,")))",sep="")
用dbConnect 连接数据库
con<-dbConnect(drv,username="scott",password="tiger",dbname=connect.string)
网友评论