我遇到了一个错误导致我的应用程序停止工作。
然而,我还没有达到我的最大连接池。我有RDS,在我的监控页面上,我发现在出现此错误时连接数为33,我的默认最大连接数为100。
因此,我想这可能是由于我的连接泄漏引起的。
这是我用来连接数据库的
Timeout expired.
在从池中获得连接之前,超时时间已过。
这可能是因为所有池化的连接都在使用中,并且已达到最大池大小。然而,我还没有达到我的最大连接池。我有RDS,在我的监控页面上,我发现在出现此错误时连接数为33,我的默认最大连接数为100。
因此,我想这可能是由于我的连接泄漏引起的。
这是我用来连接数据库的
DBLayer
类。public static DataTable GetDataTable(SqlCommand command, IsolationLevel isolationLevel = IsolationLevel.ReadUncommitted)
{
using (new LoggingStopwatch("Executing SQL " + command.CommandText, command.Parameters))
{
using (var connection = new SqlConnection(connectionString))
using (var dataAdapter = new SqlDataAdapter(command))
{
command.Connection = connection;
command.CommandTimeout = ShopexConfiguration.SqlTimeout;
connection.Open();
var transaction = connection.BeginTransaction(isolationLevel);
command.Transaction = transaction;
try
{
var result = new DataTable();
dataAdapter.Fill(result);
transaction.Commit();
return result;
}
catch
{
try
{
transaction.Rollback();
}
catch (Exception)
{
//
// This catch block will handle any errors that may have occurred
// on the server that would cause the rollback to fail, such as
// a closed connection.
}
throw;
}
}
}
}
我想知道,这会导致连接泄漏吗?
我看过这篇博客:
任何帮助都是受欢迎的?