Oracle Connection请求超时c#

时间:2017-11-22 10:35:08

标签: c# oracle

我目前正在开发一个可以执行一些不同操作的应用程序,但我遇到的问题是应用程序仅适用于我的和其他开发计算机,而不适用于非开发笔记本电脑和运行的Virtual PC批量分配

当我尝试在批量PC和笔记本电脑上运行发布文件时,我收到以下错误。

Exception took place in:  PR Get(OracleInternal.ConnectionPool.ConnectionString, Boolean, OracleInternal.ConnectionPool.CriteriaCtx, System.String, Boolean)
Data:  System.Collections.ListDictionaryInternal
H Result:  -2147467259
Message:  Connection request timed out
Stack Trace:     at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, CriteriaCtx criteriaCtx, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, CriteriaCtx criteriaCtx, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OracleConnectionDispenser 3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, CriteriaCtx criteriaCtx)
at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
at BatchErrorScreenshotter.Program.DatabaseChecker.GetAllBatchesFromDB() in C:\Users\clm\documents\visual studio 2015\Projects\BatchErrorScreenshotter\BatchErrorScreenshotter\Program\DatabaseChecker.cs:line 25

使用的连接字符串

<connectionStrings>
<add name="OracleConnectionXALP" providerName="Oracle.ManagedDataAccess.Client"
  connectionString="User Id=XXXXX;Password=XXXXX;Data Source=XALP;Min Pool Size=2; Connection Lifetime=30;Connection Timeout=10;Incr Pool Size=1;Decr Pool Size=1"/>

我试图摆弄它,改变不同的值而不会对结果产生太大的改变。我尝试添加最大池大小200,比默认值100增加。但它没有用。

以下是我与数据库建立连接的代码,它返回所需的数据。 (行:25是 - > conn.Open())

public DatabaseCheckWrapper GetAllBatchesFromDB()
    {
        try
        {
            using (var conn = new OracleConnection(ConfigurationManager.ConnectionStrings["OracleConnectionXALP"].ConnectionString))
            {
                conn.Open(); // Line 25, Connection error happens here
                DatabaseCheckWrapper dbw = new DatabaseCheckWrapper();
                OracleCommand cmd = new OracleCommand()
                {
                    CommandText = $"xal_supervisor.batchmonitor_pkg.get_batchmonitor",
                    CommandType = CommandType.StoredProcedure,
                    Connection = conn
                };

                OracleParameter p1 = new OracleParameter
                { OracleDbType = OracleDbType.RefCursor, ParameterName = "batchmonitor_ud", Direction = ParameterDirection.Output };

                cmd.Parameters.AddRange(new[] { p1 });

                var reader = cmd.ExecuteReader();

                var batches = new List<BatchDeadCheck>();
                while (reader.Read())
                {
                    var batch = new BatchDeadCheck();
                    batch.DXDEMINUTTER = reader.GetInt32(0);
                    batch.ACCEPTDXDEMINUTTER = reader.GetInt32(1);
                    // ACTION NAME IS ?Mainwindowtitle?
                    batch.ACTIONNAME = $"{reader.GetString(2)} (tilsluttet)";
                    batch.SESSIONSTATUS = reader.GetString(3);
                    batch.ADVERSELEMAIL = reader.GetString(4);
                    batch.ILIVETID = reader.GetInt32(5);
                    batches.Add(batch);
                }
                dbw.DisplayText = $"> Database batch check was run at {DateTime.Now.ToString("T")}";
                dbw.Batches = batches;
                conn.Close();
                return dbw;
            }
        }
        catch (Exception e)
        {
            DatabaseCheckWrapper dbwError = new DatabaseCheckWrapper();
            dbwError.DisplayText = $"!!Error has occurred while retrieving data from the Database!!";
            dbwError.Batches = null;
            dbwError.Exception = e;
            return dbwError;
        }
    }

到目前为止,我在google上查看了Google首页上的每个链接 &#34; c#连接请求超时 &#34; 我已经在Oracle® Data Provider for .NET中对oracle连接池进行了一些阅读而没有得到任何真正的解决方案

更新 我决定尝试ping数据库服务器,发现我的笔记本电脑无法访问它,但批处理PC可以。所以我现在要在Batch PC上进行测试。我在Batch PC上第一次运行时也出现了以下错误日志

Data:  System.Collections.ListDictionaryInternal
Inner Exception:  OracleInternal.Network.NetworkException (0x00002F7A): ORA-12154: TNS:could not resolve the connect identifier specified
at OracleInternal.Network.AddressResolution..ctor(String TNSAlias, String instanceName)
at OracleInternal.Network.OracleCommunication.DoConnect(String tnsDescriptor)
at OracleInternal.Network.OracleCommunication.Connect(String tnsDescriptor, Boolean doNAHandshake, String IName)
at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession, CriteriaCtx criteriaCtx, String instanceName)
Message:  ORA-12154: TNS:could not resolve the connect identifier specified
Stack Trace:     at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, CriteriaCtx criteriaCtx, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, CriteriaCtx criteriaCtx, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, CriteriaCtx criteriaCtx)
at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
at BatchErrorScreenshotter.Program.DatabaseChecker.GetAllBatchesFromDB() in C:\Users\clm\documents\visual studio 2015\Projects\BatchErrorScreenshotter\BatchErrorScreenshotter\Program\DatabaseChecker.cs:line 25

2 个答案:

答案 0 :(得分:2)

您是否检查过错误的机器上是否有tnsnames.ora文件ORA-12154:TNS:无法解析指定的连接标识符

检查系统环境变量“TNS_ADMIN”,如果没有找到,则参考应放置tnsnames.ora的文件夹创建它。然后从开发电脑中复制tnsnames.ora。

答案 1 :(得分:0)

已通过验证,可以从安装数据库代理的服务器访问Oracle数据库主机/端口。

您可以在此处找到有关网络要求的更多信息。

https://docs.appdynamics.com/display/PRO44/Database+Visibility+System+Requirements#DatabaseVisibilit ...