在 Oracle SQL Developer 中使用 tnsnames.ora
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2019230/
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
Use tnsnames.ora in Oracle SQL Developer
提问by Peter Lang
I am evaluating Oracle SQL Developer.
我正在评估Oracle SQL Developer。
My tnsnames.ora
is populated, and a tnsping
to a connection defined in tnsnames.ora
works fine. Still, SQL Developer does not display any connections.
我的tnsnames.ora
填充,并且tnsping
在一个连接定义tnsnames.ora
工作正常。尽管如此,SQL Developer 不显示任何连接。
Oracle SQL Developer Soars mentions, that if
Oracle SQL Developer Soars提到,如果
you have Oracle client software and a tnsnames.ora file already installed on your machine, Oracle SQL Developer will automatically populate the Connections navigator from the net service names defined in tnsnames.ora.
您的机器上已经安装了 Oracle 客户端软件和 tnsnames.ora 文件,Oracle SQL Developer 将自动从 tnsnames.ora 中定义的网络服务名称填充连接导航器。
I also tried to set my TNS_ADMIN
environment variable, but after restarting SQL Developer there are still no connections displayed.
我也尝试设置我的TNS_ADMIN
环境变量,但在重新启动 SQL Developer 后仍然没有显示任何连接。
Any ideas?
Anyone successfully working with SQL Developer and tnsnames.ora?
有任何想法吗?
有人成功使用 SQL Developer 和 tnsnames.ora 吗?
回答by Chandra Sekhar
- In SQLDeveloperbrowse
Tools --> Preferences
, as shown in below image. - In the Preferencesoptions
expand Database --> select Advanced --> under "Tnsnames Directory" --> Browse the directory
where tnsnames.orapresent. - Then click on Ok,
as shown in below diagram.
tnsnames.oraavailable atDrive:\oracle\product\10x.x.x\client_x\NETWORK\ADMIN
- 在SQLDeveloper 中浏览
Tools --> Preferences
,如下图所示。 - 在tnsnames.ora存在的首选项选项
expand Database --> select Advanced --> under "Tnsnames Directory" --> Browse the directory
中。 - 然后点击确定,如下图所示。
tnsnames.ora可在Drive:\oracle\product\10x.x.x\client_x\NETWORK\ADMIN
Now you can connect via the TNSnamesoptions.
现在您可以通过TNSnames选项进行连接。
回答by Peter Lang
This excellent answerto a similar question (that I could not find before, unfortunately) helped me solve the problem.
这个对类似问题的出色回答(不幸的是我以前找不到)帮助我解决了这个问题。
Copying Content from referenced answer :
从参考答案复制内容:
SQL Developer will look in the following location in this order for a tnsnames.ora file
$HOME/.tnsnames.ora
$TNS_ADMIN/tnsnames.ora
TNS_ADMIN lookup key in the registry
/etc/tnsnames.ora ( non-windows )
$ORACLE_HOME/network/admin/tnsnames.ora
LocalMachine\SOFTWARE\ORACLE\ORACLE_HOME_KEY
LocalMachine\SOFTWARE\ORACLE\ORACLE_HOMEIf your tnsnames.ora file is not getting recognized, use the following procedure:
Define an environmental variable called TNS_ADMIN to point to the folder that contains your tnsnames.ora file.
In Windows, this is done by navigating to Control Panel > System > Advanced system settings > Environment Variables...
In Linux, define the TNS_ADMIN variable in the .profile file in your home directory.Confirm the os is recognizing this environmental variable
From the Windows command line: echo %TNS_ADMIN%
From linux: echo $TNS_ADMIN
Restart SQL Developer Now in SQL Developer right click on Connections and select New Connection.... Select TNS as connection type in the drop down box. Your entries from tnsnames.ora should now display here.
SQL Developer 将按此顺序在以下位置查找 tnsnames.ora 文件
$HOME/.tnsnames.ora
$TNS_ADMIN/tnsnames.ora
TNS_ADMIN 注册表中查找键值
/etc/tnsnames.ora (非windows)
$ORACLE_HOME/network/admin/tnsnames.ora
LocalMachine\SOFTWARE\ORACLE\ORACLE_HOME_KEY
LocalMachine\SOFTWARE \ORACLE\ORACLE_HOME如果您的 tnsnames.ora 文件未被识别,请使用以下步骤:
定义一个名为 TNS_ADMIN 的环境变量以指向包含 tnsnames.ora 文件的文件夹。
在 Windows 中,这是通过导航到控制面板 > 系统 > 高级系统设置 > 环境变量...来完成的。
在 Linux 中,在主目录的 .profile 文件中定义 TNS_ADMIN 变量。确认操作系统正在识别这个环境变量
从 Windows 命令行:echo %TNS_ADMIN%
来自 linux: echo $TNS_ADMIN
重新启动 SQL Developer 现在在 SQL Developer 中右键单击 Connections 并选择 New Connection...。在下拉框中选择 TNS 作为连接类型。您来自 tnsnames.ora 的条目现在应该显示在这里。
回答by Jim
I had the same problem, tnsnames.ora
worked fine for all other tools but SQL Developer would not use it. I tried all the suggestions on the web I could find, including the solutions on the link provided here.
Nothing worked.
我有同样的问题,tnsnames.ora
适用于所有其他工具,但 SQL Developer 不会使用它。我尝试了网上能找到的所有建议,包括此处提供的链接上的解决方案。
没有任何效果。
It turns out that the database was caching backup copies of tnsnames.ora
like tnsnames.ora.bk2
, tnsnames09042811AM4501.bak
, tnsnames.ora.bk
etc. These files were not readable by the average user.
事实证明,该数据库缓存的备份副本tnsnames.ora
一样tnsnames.ora.bk2
,tnsnames09042811AM4501.bak
,tnsnames.ora.bk
等,这些文件并没有被普通用户可读。
I suspect sqldeveloper is pattern matching for the name and it was trying to read one of these backup copies and couldn't. So it just fails gracefully and shows nothing in drop down list.
我怀疑 sqldeveloper 是名称的模式匹配,它试图读取这些备份副本之一,但不能。所以它只是优雅地失败并且在下拉列表中没有显示任何内容。
The solution is to make all the files readable or delete or move the backup copies out of the Admin directory.
解决方案是使所有文件可读或删除或将备份副本移出 Admin 目录。
回答by marchelloUA
This helped me:
这帮助了我:
Posted: 8/12/2011 4:54
发布时间:2011 年 8 月 12 日 4:54
Set tnsnames directory tools->Preferences->Database->advanced->Tnsnames Directory
设置tnsnames目录工具->Preferences->Database->advanced->Tnsnames Directory
https://forums.oracle.com/forums/thread.jspa?messageID=10020012�
https://forums.oracle.com/forums/thread.jspa?messageID=10020012
回答by dinvlad
On the newer versions of macOS, one also has to set java.library.path
. The easiest/safest way to do that [1] is by creating ~/.sqldeveloper/<version>/sqldeveloper.conf
file and populating it as such:
在较新版本的 macOS 上,还必须设置java.library.path
. 最简单/最安全的方法 [1] 是通过创建~/.sqldeveloper/<version>/sqldeveloper.conf
文件并按如下方式填充它:
AddVMOption -Djava.library.path=<instant client directory>