Pooling:more than one connection to a database

余生颓废 提交于 2019-12-24 14:04:22

问题


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

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

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.

UPDATE

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

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

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

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


回答1:


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.



来源:https://stackoverflow.com/questions/17934643/poolingmore-than-one-connection-to-a-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!