c# - 打开数据连接

标签 c# database connection

在 c#.net 中,当您打开与数据库的连接时,在我的例子中是 oracle,是否涉及很多开销?我猜不是因为连接池。所以我说的正确吗,每次我打开一个连接时,它实际上从池中抓取一个打开的连接,如果池中没有可用连接,它就会打开一个新连接?

谢谢!

最佳答案

你是对的。有很多解释 ADO 连接池的好文章。例如,MSDN - SQL Server Connection Pooling (ADO.NET) ,它说:

Connection pooling reduces the number of times that new connections must be opened. The pooler maintains ownership of the physical connection. It manages connections by keeping alive a set of active connections for each given connection configuration. Whenever a user calls Open on a connection, the pooler looks for an available connection in the pool. If a pooled connection is available, it returns it to the caller instead of opening a new connection. When the application calls Close on the connection, the pooler returns it to the pooled set of active connections instead of closing it. Once the connection is returned to the pool, it is ready to be reused on the next Open call.

关于c# - 打开数据连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2524790/

相关文章:

c# - 由于 "pending requests working on this transaction",EntityFramework SaveChanges 间歇性异常

c# - socket.io-client 足以作为 XSockets.NET 服务器的套接字客户端吗?

c# - 允许一个方法只接受数字?

database - Postgres 等待事务完成

post - 调用 mandrill api 时连接拒绝 curl 错误

c# - for循环调用字符串变成 bool 值

java - Solr ; "rookie"问题

database - 描述交易并解释主要原则

java - 使用我的 Java 库将 Android 应用程序连接到本地 MySQL DB

java - NettyIO 捕获连接超时