池化:与数据库的多个连接 [英] Pooling:more than one connection to a database

查看:106
本文介绍了池化:与数据库的多个连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑Pooling是否真的可以与vb.net一起使用。我在下面的查询中使用了
来检查来自不同PC的数据库连接。

I have a doubt that whether Pooling actually works with vb.net. I used below query to check the connection to the database from different pc.

SELECT hostname,p.status,[program_name],loginame,name
FROM Master..sysprocesses  as p join master.dbo.sysdatabases as  d on p.dbID = d.dbID
WHERE p.ecid=0 and p.hostname<>'' 
order by name

在输出中,我看到了来自一个pc到同一个数据库。

In the output i saw more than one connection from a pc to the same database.

所以我对此表示怀疑。在我的vb.net应用程序中,我只打开了一次连接,所以我想连接将从同一池,因此从PC到数据库只有一个打开的连接。

So i got doubt about this.In my vb.net application i open connection only once so i was thinking like the connection will be used from same pool,so there will be only one open connection to a database from a PC.

更新

我有一个vb.net应用程序,该应用程序利用到SQL Server数据库的连接。

I have a vb.net application which makes use of connection to SQL server databases.


  1. 如果我打开同一程序的多个实例,那么连接将从同一池还是从不同池中提取?

  1. If i open a multiple instances of same program then connection will be drawn from same pool or different pool?

如果我们打开不同的exe,但是两个都打开了到相同数据库的连接,那么两者将使用相同的连接池吗?

If we open different exe but both open connection to same databases then same connection pool will be used by both?

当我们在SQL Server中运行查询时,许多连接从同一台PC显示到同一DB。

When we run query in SQL server many connections are shown to same DB from same PC.

推荐答案

池不保证单个连接。对于每个并发活动(逻辑)连接,您需要一个物理连接。因此,如果每个连接实例有10个线程,或者由于某种原因在单个线程上打开10个连接,则将看到10个物理连接。

Pooling does not guarantee a single connection. For each concurrently active (logical) connection you need one physical connection. So if you have 10 threads each using a connection instance, or for some reason are opening 10 connections on a single thread, you will see 10 physical connections.

单个会话分配给单个连接。每个连接最多可以同时有一个会话。

A single session is assigned to a single connection. Each connection can have at most one session at the same time.

这篇关于池化:与数据库的多个连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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