2

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.

Elrond_EGLDer
  • 47,430
  • 25
  • 189
  • 180
klautern
  • 439
  • 1
  • 5
  • 22

1 Answers1

1

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.

Community
  • 1
  • 1
radu florescu
  • 4,199
  • 10
  • 56
  • 90