0
You’re making this mistake. I’m using postgres
Erro ao buscar servidor por id: Timeout while getting a connection from pool.
A first chance exception of type 'System.Exception' occurred in BackupDAO.dll
Method
public Servidor buscarPorID(int id)
{
try
{
DAOFactoryNuvem dao = new DAOFactoryNuvem();
conexao = dao.CriaConexao();
String sql = "select * from servidor where id = "+id;
NpgsqlCommand sqlCon = new NpgsqlCommand(@sql, conexao);
conexao.Open();
NpgsqlDataReader drCon;
drCon = sqlCon.ExecuteReader();
while (drCon.Read())
{
Servidor servidor = new Servidor(Convert.ToInt32(drCon[0]), drCon[1].ToString(), drCon[2].ToString());
drCon.Close();
return servidor;
}
Servidor servidor1 = new Servidor(0, "", "");
conexao.Dispose();
return servidor1;
}
catch (Exception erro)
{
Console.WriteLine("Erro ao buscar servidor por id: " + erro.Message);
throw erro;
}
finally
{
conexao.Clone();
}
}
But there are many more methods in other Daos that are called at the same time, I only sent this one so as not to send everyone, because I thought that Disposis could be in the wrong place. I’ll try that there.
– meisterx7
Try to give each a Dispose() . I would recommend using only 1 Connection() and closing it. Better than opening and closing 1000 times.If possible post the rest of the code, the other Daos
– PauloHDSousa
A connectionby DAO in case?
– meisterx7