【问题标题】:Clear connection pooling in devart?清除devart中的连接池?
【发布时间】:2019-04-03 06:32:37
【问题描述】:

我有一个 Windows 服务应用程序,每分钟连接一次数据库。有时我会收到此错误:

ORA-20110: ORA-06508: PL/SQL: 找不到被调用的程序单元

解决方案已关闭并在 plsql 中重新连接数据库,但我想在应用程序端执行此操作。

所以我需要禁用所有连接池并尝试重新连接数据库。 我如何使用 devart 做到这一点?

这是我的连接

this.ConnectMode = OracleConnectMode.Default;
this.Direct = true;
this.Close();
this.Server = ConfigurationManager.AppSettings["db_hostname"];
this.Port = Convert.ToInt32(ConfigurationManager.AppSettings["db_port"]);
if (db_connection_type == "SID")
   this.Sid = ConfigurationManager.AppSettings["db_sid"];
else
   this.ServiceName = ConfigurationManager.AppSettings["db_sid"];
this.UserId = db_username;
this.Password = db_password;
this.Open();

【问题讨论】:

    标签: c# oracle database-connection connection-pooling devart


    【解决方案1】:

    我找到了oracleconnection ownclass的clearPool

    // C#
    // Sample demonstrating the use of ClearPool API in OracleConnection class
    
    using System;
    using Oracle.DataAccess.Client;
    
    class ClearPoolSample
    {
      static void Main()
      {
        Console.WriteLine("Running ClearPool sample..." );
        // Set the connection string
        string strConn = "User Id=scott;Password=tiger;Data Source=oracle;" +
                         "Min pool size=5;";
        OracleConnection conn = new OracleConnection(strConn);
    
        // Open the connection
        conn.Open();
    
        // Clears the connection pool associated with connection 'conn'
        OracleConnection.ClearPool (conn);
    
        // This connection will be placed back into the pool
        conn.Close ();
    
        // Open the connection again to create additional connections in the pool
        conn.Open();
    
        // Create a new connection object
        OracleConnection connNew = new OracleConnection(strConn);
    
        // Clears the pool associated with Connection 'connNew'
        // Since the same connection string is set for both the connections,
        // connNew and conn, they will be part of the same connection pool.
        // We need not do an Open() on the connection object before calling
        // ClearPool
        OracleConnection.ClearPool (connNew);
    
        // cleanup
        conn.Close();
        Console.WriteLine("Done!");
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-18
      • 1970-01-01
      • 1970-01-01
      • 2016-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-07
      相关资源
      最近更新 更多