创建多个数据库连接是否有任何问题 [英] Is there any problem in creating multiple database connections

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

问题描述

我开发了一个.net windows TOP-UP应用程序( HTTP LISTENERS ),它接受来自Embeded设备的请求



应用程序创建一个线程以及从设备收到的每个请求的唯一数据库连接( SQL SERVER 2008 ),并且该连接沿线程旋转,并且当线程结束时数据库连接关闭



i观察到在高峰时段收到的请求数量达到100的倍数我也从数据库中通过执行 SP_WHO 观察到接近150-200的连接状态 睡觉



创建这么多数据库连接或数据库负担是否有任何问题



一次维持这些请求的任何其他方式



请指导我......

I have developed a .net windows TOP-UP application (HTTP LISTENERS) which accepts requests from Embeded devices

the application creates a thread along with unique database connection (SQL SERVER 2008 )for every request received from the devices and that connection rotates along the thread and the database connection closes when thread ends

i have observed that at peak hours number of requests received reaches to multiples of 100 also i have observed from the database by executing "SP_WHO" nearly 150-200 connection status is under "sleeping"

Is there any problem in creating these many database connections or any burden to the database

any other way to maintain these many requests at a time

Please Guide me......

推荐答案

1.通常,数据库连接是应该使用的资源,然后尽快发布,否则数据库服务器使用的速度和内存将受到影响。



2.在你的代码中只在需要时打开连接(访问数据库数据)并关闭并尽快释放(在阅读之后或更新数据),您应该使用 try-catch-finally 块来执行此操作!
1.In generally the database connection are resources that should be used, then released as soon as possible, otherwise the speed and memory used by your database server will suffer.

2.So in your code open the connection only when is needed (access of the database data) and closed and release it as soon as possible (after the reading or updating of the data), and you should use try-catch-finally blocks for doing this!


这篇关于创建多个数据库连接是否有任何问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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