One database Connection [modified]
-
my application is Port Listener(window service) a lot of client will send data to this port in order to handle it i have used mutithreading. After receiving data from port i have to save it in database now i m using classical way to save in database like open connection save data and then close connection and dispose connection. as we know every time opening and closing connection take time . Because within a second 30 or more than 30 client is sending data to this port to this port every time opening closing connection is not idea. so please suggest how to use one connection for all request first time only it open connection and from next time my app use the open connection.
modified on Tuesday, December 22, 2009 8:05 AM
-
my application is Port Listener(window service) a lot of client will send data to this port in order to handle it i have used mutithreading. After receiving data from port i have to save it in database now i m using classical way to save in database like open connection save data and then close connection and dispose connection. as we know every time opening and closing connection take time . Because within a second 30 or more than 30 client is sending data to this port to this port every time opening closing connection is not idea. so please suggest how to use one connection for all request first time only it open connection and from next time my app use the open connection.
modified on Tuesday, December 22, 2009 8:05 AM
I don't understand your question if there is any question.
Shivendra Pandey wrote:
It means only first time the database will open from next time it use the same open connection for every request.
As long Connection is opened it will be used for request. However you need to handle connection timeout (Disconnected by unkown reasons).
Shivendra Pandey wrote:
one dedicated open connection for all request in this service
If you use app or service as "front end" (app that sits on server and it is betwen client and database) and connect to database service than that can be acheaved. That app needs to handle a multiple connection if you want to use multiple clients at the same time
-
my application is Port Listener(window service) a lot of client will send data to this port in order to handle it i have used mutithreading. After receiving data from port i have to save it in database now i m using classical way to save in database like open connection save data and then close connection and dispose connection. as we know every time opening and closing connection take time . Because within a second 30 or more than 30 client is sending data to this port to this port every time opening closing connection is not idea. so please suggest how to use one connection for all request first time only it open connection and from next time my app use the open connection.
modified on Tuesday, December 22, 2009 8:05 AM
-
my application is Port Listener(window service) a lot of client will send data to this port in order to handle it i have used mutithreading. After receiving data from port i have to save it in database now i m using classical way to save in database like open connection save data and then close connection and dispose connection. as we know every time opening and closing connection take time . Because within a second 30 or more than 30 client is sending data to this port to this port every time opening closing connection is not idea. so please suggest how to use one connection for all request first time only it open connection and from next time my app use the open connection.
modified on Tuesday, December 22, 2009 8:05 AM
Probably you don't want that. For example, if the connection is lost, what happens? If two clients try to use the connection at the same time? One client starting a transaction will in fact be starting a transaction over the connection used by everyone (for example, in Sql Server if there is a transaction, you must use it). And, finally, there is the connection pooling. By default, when you open and close a connection, the real connection keeps opened, but it is returned to the pool. Opening it again will only use the already opened connection. So, the best practice is to open the connection for each web-method and close it at the end. You can, of course, configure the maximum pool size to 1, so only one real connection will be kept open.
-
my application is Port Listener(window service) a lot of client will send data to this port in order to handle it i have used mutithreading. After receiving data from port i have to save it in database now i m using classical way to save in database like open connection save data and then close connection and dispose connection. as we know every time opening and closing connection take time . Because within a second 30 or more than 30 client is sending data to this port to this port every time opening closing connection is not idea. so please suggest how to use one connection for all request first time only it open connection and from next time my app use the open connection.
modified on Tuesday, December 22, 2009 8:05 AM
i think u should create and open the connection when your windows service starts,so during the process everywhere in your code u can use that open connection.