20151024-1连接到ORACLE数据库(20151024)
解决方案:
之前R版本为64位,无法加载成功rJava,后面使用版本为32位,就可以了
网上查找资料发现:win64安装r64,可能无法安装rJava包,下载32为安装包测试通过,下面具体过程
> install.packages('rJava')
--- 在此連線階段时请选用CRAN的鏡子 ---
警告: 无法在貯藏處http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.11中读写索引
试开URL’http://mirror.bjtu.edu.cn/cran/bin/windows/contrib/2.11/rJava_0.8-8.zip'
Content type 'application/zip' length 579084 bytes (565 Kb)
打开了URL
downloaded 565 Kb
程序包'rJava'打开成功,MD5和检查也通过
下载的程序包在
C:\Users\gh\AppData\Local\Temp\RtmpFFDopQ\downloaded_packages里
> library('rJava')
> install.packages('RJDBC')
警告: 无法在貯藏處http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.11中读写索引
also installing the dependency ‘DBI’
试开URL’http://mirror.bjtu.edu.cn/cran/bin/windows/contrib/2.11/DBI_0.2-5.zip'
Content type 'application/zip' length 390917 bytes (381 Kb)
打开了URL
downloaded 381 Kb
试开URL’http://mirror.bjtu.edu.cn/cran/bin/windows/contrib/2.11/RJDBC_0.1-6.zip'
Content type 'application/zip' length 48562 bytes (47 Kb)
打开了URL
downloaded 47 Kb
程序包'DBI'打开成功,MD5和检查也通过
程序包'RJDBC'打开成功,MD5和检查也通过
下载的程序包在
C:\Users\gh\AppData\Local\Temp\RtmpFFDopQ\downloaded_packages里
> library('RJDBC')
载入需要的程辑包:DBI
> install.packages('DBI')
警告: package 'DBI' is in use and will not be installed
警告: 无法在貯藏處http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.11中读写索引
> (.packages(all.available=TRUE))
[1] "base" "boot" "class" "cluster" "codetools"
[6] "datasets" "DBI" "foreign" "graphics" "grDevices"
[11] "grid" "KernSmooth" "lattice" "MASS" "Matrix"
[16] "methods" "mgcv" "nlme" "nnet" "rJava"
[21] "RJDBC" "rpart" "spatial" "splines" "stats"
[26] "stats4" "survival" "tcltk" "tools" "utils"
> library('DBI')
> library('RJDBC')
> drv <-JDBC("oracle.jdbc.driver.OracleDriver","D:/Program Files (x86)/R/ojdbc14.jar", identifier.quote="\"")
> conn <- dbConnect(drv, "jdbc:oracle:thin:@192.168.1.30:1521:orcl10g","sjzyk","sjzyk")
--t为数据库中的表
> dbGetQuery(conn,"select count(1) cn from t")
CN
1 0
参考资料:
http://m.blog.csdn.net/blog/paomojing/41245633
总结:之前一直在纠结rJava安装部署是否成功没有考虑本身的版本是否支持,搜索时没有准确的语言搜索
打开oracle数据库连接
> library('DBI')
> library('RJDBC')
> drv<-JDBC("oracle.jdbc.driver.OracleDriver","D:/Program Files (x86)/R/ojdbc14.jar", identifier.quote="\"")
> conn <- dbConnect(drv, "jdbc:oracle:thin:@192.168.1.30:1521:orcl10g","sjzyk","sjzyk")
解决方案:
之前R版本为64位,无法加载成功rJava,后面使用版本为32位,就可以了
网上查找资料发现:win64安装r64,可能无法安装rJava包,下载32为安装包测试通过,下面具体过程
> install.packages('rJava')
--- 在此連線階段时请选用CRAN的鏡子 ---
警告: 无法在貯藏處http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.11中读写索引
试开URL’http://mirror.bjtu.edu.cn/cran/bin/windows/contrib/2.11/rJava_0.8-8.zip'
Content type 'application/zip' length 579084 bytes (565 Kb)
打开了URL
downloaded 565 Kb
程序包'rJava'打开成功,MD5和检查也通过
下载的程序包在
C:\Users\gh\AppData\Local\Temp\RtmpFFDopQ\downloaded_packages里
> library('rJava')
> install.packages('RJDBC')
警告: 无法在貯藏處http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.11中读写索引
also installing the dependency ‘DBI’
试开URL’http://mirror.bjtu.edu.cn/cran/bin/windows/contrib/2.11/DBI_0.2-5.zip'
Content type 'application/zip' length 390917 bytes (381 Kb)
打开了URL
downloaded 381 Kb
试开URL’http://mirror.bjtu.edu.cn/cran/bin/windows/contrib/2.11/RJDBC_0.1-6.zip'
Content type 'application/zip' length 48562 bytes (47 Kb)
打开了URL
downloaded 47 Kb
程序包'DBI'打开成功,MD5和检查也通过
程序包'RJDBC'打开成功,MD5和检查也通过
下载的程序包在
C:\Users\gh\AppData\Local\Temp\RtmpFFDopQ\downloaded_packages里
> library('RJDBC')
载入需要的程辑包:DBI
> install.packages('DBI')
警告: package 'DBI' is in use and will not be installed
警告: 无法在貯藏處http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.11中读写索引
> (.packages(all.available=TRUE))
[1] "base" "boot" "class" "cluster" "codetools"
[6] "datasets" "DBI" "foreign" "graphics" "grDevices"
[11] "grid" "KernSmooth" "lattice" "MASS" "Matrix"
[16] "methods" "mgcv" "nlme" "nnet" "rJava"
[21] "RJDBC" "rpart" "spatial" "splines" "stats"
[26] "stats4" "survival" "tcltk" "tools" "utils"
> library('DBI')
> library('RJDBC')
> drv <-JDBC("oracle.jdbc.driver.OracleDriver","D:/Program Files (x86)/R/ojdbc14.jar", identifier.quote="\"")
> conn <- dbConnect(drv, "jdbc:oracle:thin:@192.168.1.30:1521:orcl10g","sjzyk","sjzyk")
--t为数据库中的表
> dbGetQuery(conn,"select count(1) cn from t")
CN
1 0
参考资料:
http://m.blog.csdn.net/blog/paomojing/41245633
总结:之前一直在纠结rJava安装部署是否成功没有考虑本身的版本是否支持,搜索时没有准确的语言搜索
打开oracle数据库连接
> library('DBI')
> library('RJDBC')
> drv<-JDBC("oracle.jdbc.driver.OracleDriver","D:/Program Files (x86)/R/ojdbc14.jar", identifier.quote="\"")
> conn <- dbConnect(drv, "jdbc:oracle:thin:@192.168.1.30:1521:orcl10g","sjzyk","sjzyk")