mysql - timeout expired 从池中获取连接之前经过的超时时间
问题描述
今天我发现一个问题,我的程序在进行 SQL 查询时冻结,并且我得到一个异常“超时已过期,在从池中获取连接之前经过的超时时间”
我的C#
请求代码:
public int LoadParameter(string parameter,string table,string condition,string find)
{
int index = 0;
SqlConnection dbConnection = new SqlConnection
{
ConnectionString = ConfigurationManager.ConnectionStrings["Connection"].ToString()
};
try
{
dbConnection.Open();
SqlCommand command = new SqlCommand
{
CommandText = string.Format(@"Select {0} FROM {1} WHERE {2} = '{3}'", parameter, table, condition, find),
Connection = dbConnection
};
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
index = reader.GetInt32(0);
}
dbConnection.Close();
SqlConnection.ClearPool(dbConnection);
return index;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return 0;
}
finally
{
dbConnection.Close();
SqlConnection.ClearPool(dbConnection);
}
}
我关闭了连接,但没有帮助。
解决方案
推荐阅读
- gnuplot - 在 Gnuplot 的多轴图中显示误差线
- json - ¿如何计算flutter文件夹中json文件的数量?
- c# - C# JsonSerializer.Serialize
- >(numbers) 将输出一个包含 0 列表的 json
- php - 无法在 Mac Big Sur 上安装 PHP yaml 扩展
- azure-blob-storage - 使用 azure storage python 客户端库时“连接”字符串的任何替代方法?
- python - 从 Python HTMLParser 返回数据
- linux - Docker 容器挂载的文件共享路径未更新
- blockchain - 如何保护基于 PoW 的区块链免受 51% 攻击?
- html - CSS 边框仅在某些 div 上
- c++ - 如何调整二维向量的大小