这花了我好几个小时。我必须让这个 .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 应用程序和数据库位于同一台机器上。