Groups | Blog | Home
all groups > sql server programming > june 2007 >

sql server programming : sleeping process


is_vlb50 NO[at]SPAM hotmail.com
6/4/2007 9:16:25 PM
I am using closed system, which can execute store procedure via jdbc
interface.
The problem is that, after every execution of store procedure exist
process in sleeping state with "awaiting command" command.
Is exist any option to manually, in code of my store procedure, say,
that process should be closed.
May be exist parametr with timeout for closing sleeping processes?
Thanks
Erland Sommarskog
6/4/2007 10:30:09 PM
(is_vlb50@hotmail.com) writes:
[quoted text, click to view]

I don't know about JDBC, but most modern client API has this features
known as connection pooling. This means that when the application
closes a connection, the API lingers to the physical connection for
some time, typically 60 seconds, and if there is a requestion for a new
connection in this time frame for a connection with the same properties,
the connection is reused.

The reason for this design is efficiency. By avoiding actual connection
sequences, the load on SQL Server is reduced.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
is_vlb50 NO[at]SPAM hotmail.com
6/7/2007 6:59:30 AM
the problem is that every call to sp create a new process and not use
connection from a pool.
so as temporary solution I want to manual close connection from store
procedure.
is exist any solution?

[quoted text, click to view]

Erland Sommarskog
6/7/2007 10:24:02 PM
(is_vlb50@hotmail.com) writes:
[quoted text, click to view]

It seems that there is a flaw in your application so that connections are
not closed properly. I don't remember under which circumstances this
happen, but be sure that you close all readers and commands before
you close the connection.

[quoted text, click to view]

You cannot close the connection from the stored procedure. (OK, so I lied,
you can by raising an error with a severity >= 20. But that requires
admin privs, and could set off alerts to operators, and nothing you use
to cover up for an application that abuses the connection pool.)


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
AddThis Social Bookmark Button