连接到 Oracle 数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17303164/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 05:07:20  来源:igfitidea点击:

Connection to an Oracle Database

oracleodbc

提问by Jamie Dixon

I recently picked up a project where I need to build some SSIS packages that extract data from a remote Oracle database and load the data into a Sql Server database. The Oracle database is an old 32-bit Oracle 8i database. The Sql Server is 64-bit Sql Server 2008R2.

我最近选择了一个项目,我需要构建一些 SSIS 包,这些包从远程 Oracle 数据库中提取数据并将数据加载到 Sql Server 数据库中。Oracle 数据库是一个旧的 32 位 Oracle 8i 数据库。Sql Server 是 64 位 Sql Server 2008R2。

I can connect to the Oracle database from an old Win XP workstation no problem. When I try and connect from the Sql Server, I can't set a handshake.

我可以从旧的 Win XP 工作站连接到 Oracle 数据库,没问题。当我尝试从 Sql Server 连接时,我无法设置握手。

I installed The Oracle Client 11g on the Sql Server box, copied the tnsnames file from the Install\Network\Admin\Sample to Install\Network\Admin and added the entry that worked on the XP workstation. When I try and create an ODBC connection using the Oracle ODBC Drviver, I get:

我在 Sql Server 机器上安装了 Oracle Client 11g,将 tnsnames 文件从 Install\Network\Admin\Sample 复制到 Install\Network\Admin 并添加了在 XP 工作站上工作的条目。当我尝试使用 Oracle ODBC Drviver 创建 ODBC 连接时,我得到:

*Unable to connect Sql State=08004 ORA-12154: TNS:could not resolve the connect identifier specified.*1

*无法连接 Sql 状态=08004 ORA-12154:TNS:无法解析指定的连接标识符。*1

My guess is that the driver can't find the TNS file. Is there anything else I have to configure? I checked the exception code via duckduckgo and I could not find anything.

我的猜测是驱动程序找不到 TNS 文件。还有什么我需要配置的吗?我通过duckduckgo检查了异常代码,但找不到任何东西。

Thanks in advance.

提前致谢。

回答by Jamie Dixon

OK, I found it I had to go into the Environment variables and define the ORACLE_HOME path. Once I did that, it connected.

好的,我发现我必须进入环境变量并定义 ORACLE_HOME 路径。一旦我这样做了,它就连接了。

Thispost got me on the right track.

这篇文章让我走上了正轨。

Thanks

谢谢

回答by Preeti Joshi

This might help someone stuck for "identifier not resolved issue": If you have already checked the environment variables : PATH, ORACLE_HOME, TNS_ADMIN, please give a close look to tnsnames.ora entry for the given dsn. I had not given proper indentationand it was failing because of that!

这可能有助于因“标识符未解决的问题”而陷入困境的人:如果您已经检查了环境变量:PATH、ORACLE_HOME、TNS_ADMIN,请仔细查看给定 dsn 的 tnsnames.ora 条目。我没有给出适当的缩进,因此它失败了!

Here is the entry with accurate indentation:

这是具有准确缩进的条目:

<dsn> =
   (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <server>)(PORT = <port>))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = <servicename>) 
    )
  )

回答by Mikey

I had a similar problem where I was getting garbage in the TNS Services name list and testing the connection took forever. I found this was caused be a typo in the system environment variable setting for the TNS_ADMIN variable, where I had a space after the directory eg c:\oracle\instantclient_ (where _ is a space) Removed and corrected the list garbage and connected straight away.

我有一个类似的问题,我在 TNS 服务名称列表中收到垃圾并且测试连接花了很长时间。我发现这是由于 TNS_ADMIN 变量的系统环境变量设置中的错字造成的,我在目录后面有一个空格,例如 c:\oracle\instantclient_(其中 _ 是一个空格)删除并更正了列表垃圾并直接连接离开。

Hope this helps.

希望这可以帮助。

回答by Junior Mayhé

Of course you must check your TNSNAMES.ora at

当然,您必须在以下位置检查您的 TNSNAMES.ora

C:\your_oracle_folder\app\oracle\product\11.2.0\server\network\ADMIN\TNSNAMES.ora

C:\your_oracle_folder\app\oracle\product\11.2.0\server\network\ADMIN\TNSNAMES.ora

You should see at the top what is your system name. In my case Oracle 11g Express is "XE". Then configure your ODBC 32 or 64 bits depending on your platform:

您应该在顶部看到您的系统名称。就我而言,Oracle 11g Express 是“XE”。然后根据您的平台配置 ODBC 32 位或 64 位:

enter image description here

在此处输入图片说明

回答by Ponting

You have to use both of either 64 bit or 32 bit as your machine configuration. Make sure your server configuration is correct.

您必须同时使用 64 位或 32 位作为您的机器配置。确保您的服务器配置正确。