Home > Database > Mysql Tutorial > Ubuntu下ruby连接Oracle

Ubuntu下ruby连接Oracle

WBOY
Release: 2016-06-07 16:51:58
Original
1093 people have browsed it

这是在Ubuntu下的操作步骤,在其它Linux下会有所不同,大体上原理类似。准备1下载ruby-oci8的最新稳定版的ruby-oci8-1.0.2.tar.g

这是在Ubuntu下的操作步骤,,在其它Linux下会有所不同,大体上原理类似。

准备

1下载ruby-oci8的最新稳定版的ruby-oci8-1.0.2.tar.gz
2 先安装好Oracle-xe-client
3 先安装好ruby

3 设置好环境变量,可以设置在/etc/environment中,也可以设置在~/.bashrc中

ORACLE_HOME="/usr/lib/oracle/xe/app/oracle/product/10.2.0/client"
LD_LIBRARY_PATH="$ORACLE_HOME/lib:$LD_LIBRARY_PATH"

注:好像不设置LD_LIBRARY_PATH只要有oracle-home也可以。

编译安装
cd [下载目录]
tar -zxvf ruby-oci8-1.0.2.tar.gz
cd ruby-oci8-1.0.2
make
make install

测试
连oracle

ruby -r oci8 -e "OCI8.new('scott', 'tiger', 'xe').exec('select sysdate from dual') do |r| puts r.join(','); end"

把scott,tiger,xe改成你的用户名密码和连接实例名,类似sqlplus scott/tiger@xe;

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template