连接池已达到最大连接数

时间:2012-07-25 10:30:22

标签: asp.net performance iis-7.5 connection-pooling informix

此方法导致错误文件已满,并显示以下错误:

Connection Pool has reached the maximum number of connections

public static int IsValidPortalUser(string p_u, string p_p) {
            int item = 0;
            using (IfxConnection ifxConnection = new IfxConnection(DB_Connection.connectionString))
            {
                IfxCommand ifxCommand = new IfxCommand();
                string str = DB_Connection.My_Decryption_2(p_p);
                try
                {
                    if (ifxConnection.State == 0)
                    {
                        ifxConnection.Open();
                    }
                     DB_Connection.DBCmd = new IfxCommand();
                     DB_Connection.DBCmd.Connection = ifxConnection;
                     DB_Connection.DBCmd.CommandText = "SELECT nvl(emp_num,0) FROM htoemp WHERE username = ? AND DECRYPT_CHAR(password, '78dfdf') = ? ";
                     DB_Connection.DBCmd.Parameters.Add("user_name", p_u);
                     DB_Connection.DBCmd.Parameters.Add("password", str);

                    IfxDataReader ifxDataReaders = ifxCommand.ExecuteReader();
                    using (ifxDataReaders)
                    {
                        if (ifxDataReaders.Read())
                        {
                            item = (int)ifxDataReaders[0];
                        }
                        ifxDataReaders.Close();
                    }
                }
                catch (ApplicationException applicationException)
                {
                }
                ifxConnection.Close();
            }
            return item;
        }

   Error Message:Connection Pool has reached the maximum number of connections.  Stack Trace :    at IBM.Data.Informix.IfxConnectionPool.ReportOpenTimeOut()
   at IBM.Data.Informix.IfxConnectionPool.Open(IfxConnection connection)
   at IBM.Data.Informix.IfxConnPoolManager.Open(IfxConnection connection)
   at IBM.Data.Informix.IfxConnection.Open()
   at DB_Connection_s.DB_Connection.IsValidPortalUser(String p_u, String p_p)
   at LoginSystem.LoginPage_ar.ValidateUser(String UserName, String Password) in H:\LoginSystem\LoginSystem\LoginPage_ar.aspx.cs:line 20
   at LoginSystem.LoginPage_ar.ibtn_login_Click(Object sender, ImageClickEventArgs e) in H:\LoginSystem\LoginSystem\LoginPage_ar.aspx.cs:line 33
   at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
   at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

现在我设置Max Pool Size=400而不是Max Pool Size=200

直到现在没有这种类型的错误。但我想知道为什么这种方法会导致这个问题。

1 个答案:

答案 0 :(得分:1)

这是一个真实的黑暗镜头,所以,如果有什么变化,请告诉我

public static int IsValidPortalUser(string p_u, string p_p) 
{ 
    int item = 0; 
    using (IfxConnection ifxConnection = new IfxConnection(DB_Connection.connectionString)) 
    { 
        IfxCommand ifxCommand = new IfxCommand(); 
        string str = DB_Connection.My_Decryption_2(p_p); 
        try 
        { 
            if (ifxConnection.State == 0) 
                ifxConnection.Open(); 
            ifxCommand.Connection = idxConnection; 
            ifxCommand.CommandText = "SELECT nvl(emp_num,0) FROM htoemp WHERE username = ? 
                                      AND DECRYPT_CHAR(password, '78dfdf') = ? "; 
            ifxCommand.Parameters.AddWithValue("user_name", p_u); 
            ifxCommand.Parameters.AddWithValue("password", str); 
            IfxDataReader ifxDataReaders = ifxCommand.ExecuteReader(); 
            using (ifxDataReaders) 
            { 
                if (ifxDataReaders.Read()) 
                { 
                    item = (int)ifxDataReaders[0]; 
                } 
                ifxDataReaders.Close(); 
            } 
        } 
    } 
    return item; 
} 

此外,根据您的Informix版本,字符串密码为reserved keyword