关于Oracle OCI驱动的使用

03-09-10 zingers
我目前已经做的:

1 下载www.oracle.com的jdbc817jdk12-nt

2 解压缩为classes12.zip 和ocijdbc8.dll

3 把ocijdbc8.dll复制到system32

4 win2000PRO平台中set path=E:\[jdbc817jdk12-nt]\;D:\Server\oracle81\bin;C:\Program Files\Oracle\jre\1.1.7\bin;...

5 设置客户端driver:oracle.jdbc.driver.OracleDriver

url:jdbc:oracle:thin:@192.168.0.25:1521:orcl

user:[user]

password:[password]

用jdbc联接提示:

java.sql.SQLException: ORA-06401: NETCMN: 无效的驱动程序指示符

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168) at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:1597) at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:354) at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:249) at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260) at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:99) at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.execute(OpenConnectionCommand.java:112) at net.sourceforge.squirrel_sql.client.mainframe.action.ConnectToAliasCommand$SheetHandler.run(ConnectToAliasCommand.java:345) at net.sourceforge.squirrel_sql.fw.util.TaskExecuter.run(TaskExecuter.java:65) at java.lang.Thread.run(Thread.java:536)

有什么建议,谢谢

1
zingers
2003-09-10 16:09
url写错了,

配置的是:

jdbc:oracle:nci8:@192.168.0.25:1521:orcl

或者jdbc:oracle:oci8:@192.168.0.25:1521

jdbc:oracle:oci8:@192.168.0.25

都不成功。

robbin
2003-09-10 16:32
老弟,OCI不是这么配滴。

标准的做法是要在客户端配置tnsnames.ora,指定连接名称,然后用这个名称来写OCI连接,例如:配置连接名称为MyHostString

Connection conn = DriverManager.getConnection

(jdbc:oracle:oci8:@MyHostString","scott","tiger");

另一个替代办法是这样写:

Connection conn = DriverManager.getConnection

("jdbc:oracle:oci8:@(description=(address=(host= myhost)

(protocol=tcp)(port=1521))(connect_data=(sid=orcl)))","scott", "tiger");

zingers
2003-09-10 16:59
恩,解决了,原来是在net8中配置一下。

谢谢。

猜你喜欢