?
Solved

ADO.Net Connection Pooling

Posted on 2004-08-25
6
Medium Priority
?
648 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Accepted Solution

by:
shovavnik earned 1600 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

770 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