从oracle公司站点
http://www.oracle.com/technology/so...cs/winsoft.html
下载
Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
instantclient-basic-win32-10.1.0.4-20050513.zip (31,436,437 bytes)
*Instant Client Package - SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client instantclient-sqlplus-win32-10.1.0.4-20050513.zip (267,941 bytes)
然后释放到c:\
然后从一台安装了oem的机器上复制
%ORACLE_HOME\network\admin\tnsnames.ora
到C:\instantclient10_1
再从http://www.anysql.net/software/ociuldr.exe
复制
ociuldr.exe 到C:\instantclient10_1
,其中ociuldr.exe 是一个文本导出工具
这样
C:\instantclient10_1将有下列文件
2005-08-05 12:36 <DIR> .
2005-08-05 12:36 <DIR> ..
2005-02-10 10:38 1,474,666 classes12.jar
2003-10-09 01:40 1,353 glogin.sql
2005-03-07 20:35 188,416 oci.dll
2005-02-10 10:35 61,712 ocijdbc10.dll
2005-08-04 11:10 49,152 ociuldr.exe
2005-03-07 19:45 274,432 ociw32.dll
2005-02-10 10:38 1,410,632 ojdbc14.jar
2005-03-04 05:02 995,600 orannzsbb10.dll
2005-03-07 20:37 1,065,436 oraocci10.dll
2005-03-07 20:36 82,325,504 oraociei10.dll
2004-12-14 20:45 22,945 README_IC.htm
2005-08-05 12:37 1,474 sqlnet.log
2002-01-08 13:11 265 sqlnet.ora
2005-02-17 21:10 684,032 sqlplus.exe
2005-07-26 12:50 1,366 tnsnames.ora
2005-08-05 12:37 917 uldrdata.txt
2005-03-07 20:37 <DIR> vc6
2005-03-07 20:37 <DIR> vc7
2005-03-07 20:37 <DIR> vc71
然后按照README_IC.htm的提示,设置环境变量
PATH为原来的PATH;C:\instantclient10_1,
SQLPATH,LOCAL,TNS_ADMIN为C:\instantclient10_1
然后运行cmd
c:>sqlplus /nolog
conn tom/tom@jia
可以发现已经能连接远程服务器了
我发现一个奇特的现象
oracle服务器为10.1.0.4的jia可以用
conn tom/tom@//10.6.99.120:1521/jia连接
而oracle服务器为9.2.0.6的075不可以用
conn tom/tom@//10.6.99.75:1521/epras连接
ociuldr工具的运行也反映了这个问题
--------------------------------
C:\instantclient10_1>sqlplus /nolog
SQL*Plus: Release 10.1.0.4.0 - Production on Fri Aug 5 12:32:54 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn tom/tom@jia
????
SQL> conn tom/tom@jia
????
SQL> select cout(*) from tab;
select cout(*) from tab
*
? 1 ?????:
ORA-00936: ?????
SQL> select count(*) from tab;
COUNT(*)
----------
54
SQL> conn tom/tom@//10.6.99.120:1521/jia
????
SQL> conn tom/tom@//10.6.99.75:1521/epras
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
??: ?????? ORACLE?
SQL>
SQL> exit
C:\instantclient10_1>ociuldr user=tom/tom@jia query="select * from tab"
3100 bytes allocated for column TNAME (1)
800 bytes allocated for column TABTYPE (2)
4100 bytes allocated for column CLUSTERID (3)
0 rows exported at 2005-08-05 12:36:08
54 rows exported at 2005-08-05 12:36:08
C:\instantclient10_1>ociuldr user=tom/tom@//10.6.99.120:1521/jia query="select *
from tab"
3100 bytes allocated for column TNAME (1)
800 bytes allocated for column TABTYPE (2)
4100 bytes allocated for column CLUSTERID (3)
0 rows exported at 2005-08-05 12:36:41
54 rows exported at 2005-08-05 12:36:41
C:\instantclient10_1>ociuldr user=tom/tom@075 query="select * from tab"
3100 bytes allocated for column TNAME (1)
800 bytes allocated for column TABTYPE (2)
4100 bytes allocated for column CLUSTERID (3)
0 rows exported at 2005-08-05 12:37:02
57 rows exported at 2005-08-05 12:37:02
C:\instantclient10_1>ociuldr user=tom/tom@//10.6.99.75:1521/epras query="select
* from tab"
Cannot connect as tom/tom@//10.6.99.75:1521/epras.
Connection failed. Exiting...
C:\instantclient10_1>
--------------------------------
# TNSNAMES.ORA Network Configuration File: D:\oracle\ora92\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
tnsnames.ora内容
075 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.6.99.75)(PORT = 1521))
)
(CONNECT_DATA =
(SID = epras)
(SERVER = DEDICATED)
)
)
JIA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.6.99.120)(PORT = 1521))
)
(CONNECT_DATA =
(SID = jia)
(SERVER = DEDICATED)
)
)
---------------------------------------------------------------------------------------------------------
10G 中Instant Client 的使用
从10G开始,Oracle 提供了一个较为轻量级的客户包,叫做
Instant Client. 将它安装好后,就不用再安装庞大的
Oracle Client了. 这对于应用程序的分发是一个改进.
(用winrar3.3压缩后大概27M)
步骤:
1. 从OTN 下载几个压缩包,解压到一个目录, c:\instant client
instantclient-basic-win32-10.1.0.2.zip : 这是最核心的包
instantclient-jdbc-win32-10.1.0.2.zip: 包含JDBC Driver的包
instantclient-sqlplus-win32-10.1.0.2.zip: 最简单的SQLPLUS包
2. 配置环境变量和tnsnames.ora/sqlnet.ora文件
首先, PATH变量中加入 c:\instant client
如果你的机器从来没有安装过ORACLE的软件,注册表中
应该没有下面这个键:
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
因此,我们可以写一个批处理的文件,手工的添加
环境变量, 例如:
set NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK
最后,再配置tnsnames.ora和sqlnet.ora. 如果本机找
不到示例文件,就从server上拷贝一个.
3. 如果开发JAVA应用程序,还要配置一些环境变量,
例如CLASSPATH,JAVA_HOME等等. CLASSES12.jar 文件是
必须的,其他的根据需要添加.
4. 如果启动SQLPLUS时出现下面的错误:
ORA-12545: Connect failed because target host or object does not exist
试着把tnsnames.ora 中的host 改成IP地址.