日期:2014-05-16  浏览次数:20558 次

oracle10g instant client安装及java通过oci访问数据库

windows下安装配置oracle即时客户端

1.下载

http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

?

windows: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

Version 10.2.0.4
? Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
?instantclient-basic-win32-10.2.0.4.zip (34,742,358 bytes)

?

linux:http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

Version 10.2.0.4

Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications

basic-10.2.0.4.0-linux-x86_64.zip (36,600,123 bytes) (cksum - 796765058)

oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm (34,654,975 bytes) (cksum - 2995184583)

?

2.解压

将下载的instantclient-basic-win32-10.2.0.4.zip解压到如:c:\instantclient_10_2下。

3.设置环境变量

//将即时客户端路径加入环境变量

path???????????????????????????????????????c:\instantclient_10_2

//tnsnames.ora 文件的位置
TNS_ADMIN????????????????????????????c:\instantclient_10_2

//指定字符集
NLS_LANG??????????????????????????????
SIMPLIFIED CHINESE_CHINA.ZHS16GBK

?

4.设置myeclipse

打开myeclipse(我的是5.5ga)在参数设置中找到如jbossx.x(4)的paths项,在append to library path中add dir,在弹出窗中选择客户端路径添加,ok。(如果你用的是完整客户端,将它的bin目录添加进来,主要是识别dll文件)

?

如果不这样设置,直接运行jboss-bin-run.bat访问数据库不会出错,而在myeclipse里启动jboss调试会报:

java.lang.UnsatisfiedLinkError:?no?ocijdbc10?in java.library.path at java.lang.ClassLoader.loadLibrary

[参见:http://blog.sina.com.cn/s/blog_5f7ace1d0100ozzt.html]

5.oci数据源配置

要使程序能访问数据库需将客户端中的ojdbc14.jar放入jboss下如default下的lib中;

将数据源配置文件中url连接串由

jdbc:oracle:thin:@ip:1521:SID

改为

jdbc:oracle:oci:@tnsname配置文件中的标识

?

redhat下安装配置oracle即时客户端

(本配置含sqlplus)

1.安装

rpm -ivh oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm

rpm -ivh oracle-instantclient-sqlplus-10.2.0.4-1.x86_64.rpm

2.配置

vim /etc/profile???? //这个地方最好还是操作.bash_profile比较好
添加内容
export ORACLE_HOME=/usr/lib/oracle/10.2.0.4/client64
export ORACLE_BASE=/usr/lib/oracle/10.2.0.4
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:${LD_LIBRARY_PATH}
export TNS_ADMIN=$ORACLE_HOME/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export PATH=$PATH:$ORACLE_HOME/bin

?

3.tnsname.ora

这个文件直接从现有的复制一个就行了,放到lib目录下

?

?4.注意

如果在用sqlplus测试时报:

ORA-12154: TNS:could not resolve the conn