[英]Clear connection pooling in devart?
我有一個Windows服務應用程序,每分鍾連接到數據庫。 Somethimes我得到這個錯誤:
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();
我找到了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!");
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.