Ado.Net - 如何使用连接池? [英] Ado.Net - How to use connection pooling?

查看:103
本文介绍了Ado.Net - 如何使用连接池?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET允许其依据是什么我读过连接池仅仅是通过添加参数的App.config

.Net allows connection pooling which based on what I've read is simply by adding parameters to App.config

现在的问题是,我,我想在我的code使用连接池做什么? 在我的code我打开每一次数据需要有一个连接,我只要我完成关闭它。是我该做什么特别的复用连接?

The question is, am I suppose to do anything in my code to use the connection pool? In my code I open a connection every time data is needed and I close it as soon as I'm done. Am i suppose to do anything special to reuse connections?

推荐答案

您不需要,只要你的连接使用相同的连接字符串做什么特别的事情。使用该连接,将其关闭,并会自动返回到池中。

You don't need to do anything special as long as your connections use the same connection string. Use the connection, close it and will automatically return to the pool.

SQL Server连接池

连接的每个进程池,每个应用程序域,每   连接字符串并在集成的安全性时,每个视窗   身份。连接字符串也必须完全匹配;关键字   以不同的顺序进行相同的连接供给将被汇集   分开。

Connections are pooled per process, per application domain, per connection string and when integrated security is used, per Windows identity. Connection strings must also be an exact match; keywords supplied in a different order for the same connection will be pooled separately.

您可以配置在<某游泳池相关选项href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx">connection字符串本身:

  • 在池(默认启用)
  • 在连接生存期(或负载平衡超时)
  • 在争取
  • 在最大池大小
  • 在小池大小

这篇关于Ado.Net - 如何使用连接池?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆