I am using the standard Oracle driver to connect to the database, but I can’t really agree with my colleagues on the lifespan of OracleConnection. Is it expensive to create? Is it thread safe? Can I reuse it between request, or should I create a new one for every request?
I would be grateful for a bit more detailed explanation which way of using it is preferred and why.
Please correct me if I am wrong, but it seems that by default the oracle driver pools connections to the database automatically. So the best practise here seems to create a new OracleConnection object before every request and dispose it after – it will be taken from the connection pool if available or created otherwise.