DriverConnectionProvider

DriverConnectionProvider

我正在使用旧的网络应用程序。它扩展了NHibernate的DriverConnectionProvider以发出数据库连接。以下是代码。

public class NewConnectionProvider : DriverConnectionProvider
{
   public override System.Data.IDbConnection GetConnection()
   {
        IDbConnection conn = base.GetConnection();
        //execute a SP here.. to set up proxy user to connect to
        //oracle db
       return conn;
   }

}

 //connection string
<add name="connname" connectionString="Data Source=(DESCRIPTION =(ADDRESS_LIST = (ADDRESS =
(PROTOCOL = TCP)(HOST = .....)(PORT = ....)))(CONNECT_DATA = (SERVER = DEDICATED)
(SERVICE_NAME = ....)));Min Pool Size=5;Max Pool Size=500;Proxy User Id=....;
 Proxy Password=.....;Validate Connection=True;Connection Timeout=100;" />


问题:我们遇到的问题是,连接数量增加到连接字符串的Max Pool Size。有时我们会收到连接超时错误。在这种情况下,连接池如何工作?我还需要覆盖DriverConnectionProvider.CloseConnection吗?如果是,我什么时候需要打电话?系统正在使用NHibernate,Oracle 11g。

最佳答案

似乎连接从未关闭。您可能需要实施,

public void CloseConnection(IDbConnection connection)


在您的ConnectionProvider中。 Read more

关于c# - 扩展NHibernate DriverConnectionProvider类,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30581328/

10-09 15:16