oracle 如何判断 .net 调用使用了哪个 tnsnames.ora 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3073219/
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
How can you tell which tnsnames.ora file is used by a .net call?
提问by dtc
I have multiple versions of Oracle and it saved tnsnames.ora files all over the place. Older ones got stored in program files under oracle but newer ones got stored under an app directory in my hard drive.
我有多个版本的 Oracle,它到处都保存了 tnsnames.ora 文件。旧的存储在 oracle 下的程序文件中,但新的存储在我硬盘的应用程序目录下。
I'm using the .net libraries provided by Oracle to connect with a .net app and it's telling me it cannot find the name I want to connect to.
我正在使用 Oracle 提供的 .net 库来连接 .net 应用程序,它告诉我它找不到我想要连接的名称。
I've updated all the tnsnames.ora files I could find. Is there a way to tell what tnsnames.ora my app is trying to use to connect to Oracle with?
我已经更新了我能找到的所有 tnsnames.ora 文件。有没有办法告诉我的应用程序试图使用什么 tnsnames.ora 来连接到 Oracle?
回答by DavidC
Coming late to the party, but I've used Sysinternals'procmon.exe for doing something like this. Here are my notes to myself:
迟到了,但我已经使用Sysinternals 的procmon.exe 来做这样的事情。以下是我给自己的笔记:
- Start procmon.exe
- File > Capture Eventsto turn off capturing
- Press the Show File System Activitybutton (the rest on the right should be unset)
- File > Capture Eventsto start capturing
- Perform the activity that you want monitored
- File > Capture Eventsto stop capturing
- Tools > File Summaryto find tnsnames.ora in the filename list
- 启动procmon.exe
- 文件 > 捕获事件以关闭捕获
- 按Show File System Activity按钮(右侧的其余部分应取消设置)
- 文件 > 捕获事件开始捕获
- 执行您想要监控的活动
- 文件 > 捕获事件以停止捕获
- 工具 > 文件摘要以在文件名列表中查找 tnsnames.ora
回答by Waleed Al-Balooshi
The following links might provide some information:
以下链接可能会提供一些信息:
http://www.dba-oracle.com/t_windows_tnsnames.ora_file_location.htm
http://www.dba-oracle.com/t_windows_tnsnames.ora_file_location.htm
http://dbaforums.org/oracle/index.php?showtopic=2554
http://dbaforums.org/oracle/index.php?showtopic=2554
For your development environment you might try putting the tnsnames.ora in the directory where your program executables are generated for now while you figure out which one is being used. The first tnsnames.ora that is used is the one in the current directory where the application is run from.
对于您的开发环境,您可以尝试将 tnsnames.ora 放在生成程序可执行文件的目录中,同时找出正在使用的是哪个。使用的第一个 tnsnames.ora 是运行应用程序的当前目录中的那个。
回答by user370640
You can use the environment variable TNS_ADMIN to consolidate all connections to one place. It is very helpful especially in the multiple home environments.
您可以使用环境变量 TNS_ADMIN 将所有连接合并到一处。它非常有用,尤其是在多个家庭环境中。
Set TNS_ADMIN variable to the path where tnsnames.ora file is. Note that this file can be stored anywhere, but typically under one of the ORACLE_HOME\network\admin.
将 TNS_ADMIN 变量设置为 tnsnames.ora 文件所在的路径。请注意,此文件可以存储在任何位置,但通常位于 ORACLE_HOME\network\admin 之一下。
IC
我知道了
回答by GeneInDesert
I just ran into this problem. This is the comment that I put into my program: 'Note: Program built with Ora 11 OracleDataAdaptor. For this to find 'db name', the ORACLE\KEY_OraClient11g_home1 registry entry must have a value for TNS_ADMIN pointing to the correct directory for TNSNAMES.ORA.
我刚刚遇到了这个问题。这是我在程序中添加的注释:'注意:程序是用 Ora 11 OracleDataAdaptor 构建的。为了找到'db name',ORACLE\KEY_OraClient11g_home1 注册表项必须有一个指向TNSNAMES.ORA 正确目录的TNS_ADMIN 值。