Link to home
Start Free TrialLog in
Avatar of ganeshpai
ganeshpai

asked on

ADO.Net Connection Pooling

Hi Guys,

I am currently working on ASP.Net web app with Oracle 9i database,the problem i am facing is databsae connection's doesn't seem to be releasing to the pool
even after calling connection.Dispose ;  the connections are not returned to the pool and
appear as if they are busy doing some processing.

 I am using microsoft's ADO.Net provider for Oracle.

Connection string is as follows:

"user id=TESTUSER;data source='DBS';password=TESTPWD;Pooling=True;Connection Lifetime=50;Min Pool Size = 20;Max Pool Size=50"

I am using OracleHelper , Application Block from Microsoft for all Data Access.

The error i am getting is as follows :

"Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached."

The problem seems to dissapear when i have a very low value for Connection Lifetime
inside the connection string say 20 seconds... ,  which will defeat the purpose of connection pooling

The behavior i am expecting is the connections should return to the pool after
calling Dispose on them ..,so the next request coming in can grab a connection straight away from the pool..., Isn't it the way this should be working ...?
Avatar of shovavnik
shovavnik

1. Make sure you call connection.Close()

2. You don't need to dispose your connections (but you can if you want to).  .net's garbage collector takes care of that for you.  As long as the connection is closed (see #1), the connections are released to the pool.

3. How many concurrent users are there?  Maybe you really have more than 50 concurrent database connections open?

4. You're not storing the connection objects in the session, or anything like that, are you?

Avatar of ganeshpai

ASKER


I am not storing the connection is session object , no way...

currently  3   concurrent users..

Currently i am suspecting the problem is with Using block  ,  does it really  work ??

The following is the code in the OracleHelper Application block from Microsoft..

My  suspect is  the using statement is not working..

{ Using is suppose to call dispose according to Microsoft..}

            public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params OracleParameter[] commandParameters)
            {
//create & open an OracleConnection, and dispose of it after we are done.

using (OracleConnection cn = new OracleConnection(connectionString))
{
      cn.Open();
 //call the overload that takes a connection in place of the connection string
return ExecuteDataset(cn, commandType, commandText, commandParameters);
}
            }
ASKER CERTIFIED SOLUTION
Avatar of shovavnik
shovavnik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
shovavnik,

Thanks for your suggestions.

I found that the actual problem is the "usual" statement within the OracleHelper.
Looks like its not doing its job ,as it should or may be it's non-deterministic ...

No problem.  I'm glad it worked out.