Oracle 连接正常,但 ORA-12170: TNS: 执行查询时发生连接超时
我从 .net c# 控制台应用程序对 Oracle 11g 数据库执行查询时遇到一些错误。连接似乎已正确建立(conn.State
属性在以下几行之后为 Open
),
OracleConnection conn = new OracleConnection(connString);
conn.Open();
但是在启动任何查询时,我收到 ORA-12170 错误(发生连接超时)。我不认为问题出在代码中,因为针对另一个数据库的相同测试可以正常工作。
Connection.State is Open
Error: ORA-12170: TNS:Connect timeout occurred
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
at Oracle.DataAccess.Client.OracleConnection.Open()
at Proj1.DB.OracleProj1.GetOpenConn(String connString) in C:\WorkTV\src\projects\OracleProj1\source\Core\Proj1Core\DB\OracleProj1.cs:line 560
at Proj1.DB.OracleProj1.AddLog(DateTime start, DateTime end, Int32 userID, String ip, Int32 assetID, Int32 segmentID, Int32 flowID, Int32 permissionID, Int32 permissionSubtype, Int32 resultCode, String resultDescription, String resultLog) in C:\WorkTV\src\projects\OracleProj1\source\Core\Proj1Core\DB\OracleProj1.cs:line 3513
at Proj1.Util.Tool.AddLog(Int32 resultCode, String resultDescription, String resultLog) in C:\WorkTV\src\projects\OracleProj1\source\Core\Proj1Core\Util\Tool.cs:line 177
at Proj1.DB.OracleProj1.ExecuteNonQuery(OracleConnection conn, String query, String& log, Proj1Object Proj1Object) in C:\WorkTV\src\projects\OracleProj1\source\Core\Proj1Core\DB\OracleProj1.cs:line 638
at Proj1.DB.OracleProj1.TestConnection(String connString) in C:\WorkTV\src\projects\OracleProj1\source\Core\Proj1Core\DB\OracleProj1.cs:line 315
Connection.State is Closed
我可以使用同一用户通过 Oracle SQL Developer 连接到该数据库,并成功插入/删除行。
当尝试通过命令行连接sqlplus时,我收到ORA-12560:TNS:协议适配器错误,因此我无法进行任何测试。
所有 oracle 服务都在运行。
命令 Lsnrctl status
表示:
Instance "xxx", status READY, has 1 handler(s) for this service...
任何与这两个错误相关的帮助将不胜感激。
I have some errors executing queries against a oracle 11g database from a .net c# console application. The connection seems to be established properly (the conn.State
property is Open
after the following lines)
OracleConnection conn = new OracleConnection(connString);
conn.Open();
but when launching any query I get an ORA-12170 error (Connect timeout ocurred). I don't think the problem is in the code as the same test against another database works properly.
Connection.State is Open
Error: ORA-12170: TNS:Connect timeout occurred
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
at Oracle.DataAccess.Client.OracleConnection.Open()
at Proj1.DB.OracleProj1.GetOpenConn(String connString) in C:\WorkTV\src\projects\OracleProj1\source\Core\Proj1Core\DB\OracleProj1.cs:line 560
at Proj1.DB.OracleProj1.AddLog(DateTime start, DateTime end, Int32 userID, String ip, Int32 assetID, Int32 segmentID, Int32 flowID, Int32 permissionID, Int32 permissionSubtype, Int32 resultCode, String resultDescription, String resultLog) in C:\WorkTV\src\projects\OracleProj1\source\Core\Proj1Core\DB\OracleProj1.cs:line 3513
at Proj1.Util.Tool.AddLog(Int32 resultCode, String resultDescription, String resultLog) in C:\WorkTV\src\projects\OracleProj1\source\Core\Proj1Core\Util\Tool.cs:line 177
at Proj1.DB.OracleProj1.ExecuteNonQuery(OracleConnection conn, String query, String& log, Proj1Object Proj1Object) in C:\WorkTV\src\projects\OracleProj1\source\Core\Proj1Core\DB\OracleProj1.cs:line 638
at Proj1.DB.OracleProj1.TestConnection(String connString) in C:\WorkTV\src\projects\OracleProj1\source\Core\Proj1Core\DB\OracleProj1.cs:line 315
Connection.State is Closed
I can connect to this database through Oracle SQL Developer, with the same user, and insert/delete rows successfully.
When trying to connect with sqlplus throught command line I get an ORA-12560: TNS:protocol adapter error, so I cannot make any test.
All the oracle services are running.
Command Lsnrctl status
says:
Instance "xxx", status READY, has 1 handler(s) for this service...
Any help related to any of both errors will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该尝试检查您的 ODP 库。这对我有用,我内心的异常是关于 Oracle.DataAccess 和 Oracle 11g 数据库之间的不兼容性。
检查此链接和这个答案。
You should try checking your ODP Libraries. This worked for me, my inner exception was about incompatibility between Oracle.DataAccess and Oracle 11g Database.
Check this link out and this answer.