Solved

ADO.Net Connection Pooling

Posted on 2004-08-25
6
633 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 8

Expert Comment

by:shovavnik
ID: 11896934
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
ID: 11897158

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
ID: 11897193
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 8

Accepted Solution

by:
shovavnik earned 400 total points
ID: 11897265
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
ID: 11901758
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
ID: 11902633
No problem.  I'm glad it worked out.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

691 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