连接错误:Oracle.DataAccess.Client.OracleException ORA-12170
Posted
技术标签:
【中文标题】连接错误:Oracle.DataAccess.Client.OracleException ORA-12170【英文标题】:Connection Error:Oracle.DataAccess.Client.OracleException ORA-12170 【发布时间】:2011-02-03 23:34:19 【问题描述】:这花了我好几个小时。我必须让这个 .Net 应用程序在 XP 系统上运行。似乎有人弄乱了一些文件,所以 C# 中的 conn.Open() 导致了这个错误:
Connection Error:Oracle.DataAccess.Client.OracleException ORA-12170:
TNS:Connect timeout occurred at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection
conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure) at
Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn,
IntPtr opsErrCtx, Object src) at Oracle.DataAccess.Client.OracleConnection.Open() at
Service.connect(Int32 sql_choice, String databaseIdentifier, String authenticationKey) in
c:\Documents ....
这是我的 sqlnet.ora 文件:
# sqlnet.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
SQLNET.INBOUND_CONNECT_TIMEOUT = 180
SQLNET.SEND_TIMEOUT = 180
SQLNET.RECV_TIMEOUT = 180
这是 tnsnames.ora:
# tnsnames.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
ORACLE2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dell )(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = oracle2)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dell )(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
这是 listener.ora:
# listener.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oracle\product\10.2.0\db_1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dell )(PORT = 1521))
)
)
我尝试将主机名更改为 localhost, 127.0.0.1 但这不起作用。还有,
我可以从 SQL Plus 执行查询。 系统上没有防火墙 .Net 应用程序和数据库位于同一台计算机上。【问题讨论】:
您安装了哪个版本的 ODP.NET?哪个位版本?您的应用的位版本是多少? 【参考方案1】:当确定数据库是使用 DHCP 安装在 Windows 机器上时,similar SO question 已解决。正如我在那个答案中所说,如果您在带有 Oracle 的 Windows 机器上使用 DHCP,则需要安装 Microsoft Loopback Adapter。
【讨论】:
以上是关于连接错误:Oracle.DataAccess.Client.OracleException ORA-12170的主要内容,如果未能解决你的问题,请参考以下文章