首页新闻找找看学习计划

数据库连接数

0
悬赏园豆:40 [已解决问题] 解决于 2009-08-07 11:22

 最近在项目遇到一个很头疼的问题,asp.net网站发布以后,开始运行正常,但是过一段时间就不能访问,而且还要报错。

错误代码如下:

 

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. body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }

Server Error in '/' Application.

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.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: 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.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: 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.]
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +4863722
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
   System.Data.SqlClient.SqlConnection.Open() +122
   Fdays.DBUtility.MSSqlHelper.CreateSqlConn() +86
   Fdays.DBUtility.BaseHelper.GetDataSet(String strSql, String strTableName) +121
   Fdays.DBUtility.BaseHelper.GetDataSet(String strSql) +49
   Fdays.DBUtility.BaseHelper.GetDataTable(String strSql) +55
   Fdays.SqlServerDal.News.DNews.GetNewsList(MO_news mo_news, String strWhere, Int32 num) in F:\FdaysB2C\Fdays.VacationB2C\Fdays.SqlServerDal\News\DNews.cs:339
   Fdays.Bll.News.BNews.GetNewsList(MO_news mo_news, String strWhere, Int32 num) in F:\FdaysB2C\Fdays.VacationB2C\Fdays.Bll\News\BNews.cs:151
   Fdays.SiteBuild._Default.Page_Load(Object sender, EventArgs e) in F:\FdaysB2C\Fdays.VacationB2C\Fdays.WebApp\Default.aspx.cs:40
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   Fdays.SiteBuild.Public.Core.BasePage.OnLoad(EventArgs e) in F:\FdaysB2C\Fdays.VacationB2C\Fdays.WebApp\Public\Core\BasePage.cs:353
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627


Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082

问题补充: 谢谢各位了,这些问题都去查过了。的确将Max Pool Size的值加大后网站能运行了,但是连接数可达到600多个,这个值正常吗?其它的关于DataReader的地方我也释放连接了。
【舍予】的主页 【舍予】 | 初学一级 | 园豆:172
提问于:2009-08-06 10:53
< >
分享
最佳答案
0

应用池设置太小.建议在数据连接字符串加上下面两个属性:

Packet Size=8192;Max Pool Size=1000;

收获园豆:40
Insus.NET | 小虾三级 |园豆:932 | 2009-08-06 13:06
其他回答(4)
0

找找你的代码数据库连接是怎么写的

用过的资源是否即时关闭了

否则的连接池满

数据溢出你就用不了了

追太阳的向日葵 | 园豆:29 (初学一级) | 2009-08-06 11:45
0

重点检查一下你的DataReader,是否用过,没有关闭连接,导致连接池满了;

推荐:

 using (SqlDataReader dr = SQLHelper.ExecuteReader(cmdText))

{用这种方式更好}

winzheng | 园豆:8797 (大侠五级) | 2009-08-06 12:43
0

但是连接数可达到600多个,这个值正常吗?也太多了,建议检查连接是否断开,你可以进到SQL里面看一下,那些进程ID没释放掉,然后你就在你的程序里面改一下对应的ID,是否用完后就断开连接

风浪 | 园豆:2856 (老鸟四级) | 2009-08-06 16:06
0

Insus.NET 写的已经很清楚了。连接池满了。你检查你的连接池的实现代码,看看是不是有什么问题。如果没有问题。就设大一点   

jivi | 园豆:300 (菜鸟二级) | 2009-08-06 16:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册