Timeout while getting a connection from pool

0

You're giving this error. 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();
        }
    }
    
asked by anonymous 13.01.2015 / 15:49

1 answer

4

Hello,

Add in your connection string and see if it worked.

Pooling=false;

I would have kicked that there are many open connections, but I looked at you as a dispose (); then it should not be that.

    
13.01.2015 / 15:53