Solved

ADO.Net Connection Pooling

Posted on 2004-08-25
6
588 Views
Last Modified: 2008-02-01
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 ...?
0
Comment
Question by:ganeshpai
  • 3
  • 3
6 Comments
 
LVL 8

Expert Comment

by:shovavnik
Comment Utility
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?

0
 

Author Comment

by:ganeshpai
Comment Utility

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 ??

0
 

Author Comment

by:ganeshpai
Comment Utility
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);
}
            }
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 8

Accepted Solution

by:
shovavnik earned 400 total points
Comment Utility
Using does call Dispose().  I'm not sure Dispose() calls Close().  I think you're supposed to do that manually.

Try this, if you can.  This is how I manage my connections:

using (OracleConnection cn = new OracleConnection(connectionString))
{
  try
  {
     cn.Open();
 //call the overload that takes a connection in place of the connection string
return ExecuteDataset(cn, commandType, commandText, commandParameters);
  }
  finally
  {
    cn.Close(); // it always needs to be closed after the operation, even if an exception occurrs.
  }
}
0
 

Author Comment

by:ganeshpai
Comment Utility
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 ...

0
 
LVL 8

Expert Comment

by:shovavnik
Comment Utility
No problem.  I'm glad it worked out.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now