簡體   English   中英

獲取異常超時已過期。 從池中獲取連接之前經過的超時時間

[英]Getting exception Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool

出現異常提示我,我不想增加連接超時

超時時間已到。 從池中獲取連接之前已經過超時時間。 這可能是因為所有池化連接都在使用中,並且達到了最大池大小。

堆棧跟蹤:

System.Data.SqlClient.SqlConnection.Open()處System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection externalConnection,DbConnectionFactory connectionFactory)處System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)處的堆棧跟蹤。 System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe()的Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser用戶),System.Data.Linq.SqlClient.SqlProvider的System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode() Tavisca.TravelNxt.Deals.DataFeeders.DataAccessLayer.HotelDealsDataClassesDataContext處的System.Data.Linq.DataContext.ExecuteMethodCall(對象實例,MethodInfo methodInfo,Object []參數)處的System.Data.Linq.Provider.IProvider.Execute(表達式查詢)。 spInsertAsyncHotelDealFeedRequestData(Binary hotelDealData,Nullable`1 addDate)

在Tavisca.TravelNxt.Hotel.Plugins.DealsHandler.b__0(HotelDeal deal)在Tavisca.TravelNxt.Deals.DataFeeders.Entities.AsyncHotelDealFeedRequest.Add(HotelDeal hotelDeal)在System.Collections.Generic.List 1.ForEach(Action 1動作)在Tavisca.TravelNxt.Hotel.Plugins.DealsHandler.OnAfterProcessImplementation(CallHandlerContext context,Object []&inputParameters,Object&Response)處的Tavisca.TravelNxt.Hotel.Plugins.DealsHandler.UploadDeals(List`1 hotelDeals,String sessionId)

完成數據庫連接后,很可能無法正確關閉它們。 一種可能是您忘記了在幾個位置關閉一個或多個連接。 另一個是您在執行sql命令時會遇到異常,這會阻止您到達close語句。

請遵循以下模式,以確保正確關閉所有連接:

SqlConnection connection = null;
try
{
    connection = new SqlConnection(...);
    //all other stuff goes here
}
catch{}
finally
{
   if(connection != null)
      connection.Close(); //This will always close the connection, even with exceptions.
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM