即使从前端关闭连接后,Oracle连接也不会关闭

时间:2018-07-19 14:34:20

标签: ado.net

我有两种显示方法。

1)DB连接打开,并在finally块中关闭连接。

UPDATE department d
   SET cat_id = (SELECT COUNT(DISTINCT d2.dname)
                 FROM department d2
                 WHERE d2.dname <= d.dname
                ); 

2)从方法1调用的方法

         using (OracleConnection connection = 
            ORAConnection.GetOracleConnection(schemaName))
            {
          try
            {
                      Load(connection, schemaName);
            }
 catch (Exception ex)
                    {
                        if (connection.State != ConnectionState.Closed)
                        {
                            connection.Close();
                        }
                        throw new Exception(string.Format("Couldn't get offer by elivery ID ), ex);
                    }
                    finally
                    {
                        if (connection.State != ConnectionState.Closed)
                        {
                            connection.Close();
                        }
                    }
}

问题:执行第2步后未关闭连接。如AppDynamics所示,单笔交易的来电数超过2万。

0 个答案:

没有答案