Database connection

This is an old revision of this page, as edited by Eivind (talk | contribs) at 07:32, 1 August 2007 (fixed link to link directly, not to disambiguation (server)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A Database Connection is the method in computer science that allows client software to talk to database server software, whether these exist on the same machine or not. A connection is required to send commands and receive answers, usually in the form of a result set.

Connections are a key concept in data-centric programming, so much so that connection pooling was invented to simplify the process and improve performance. No command can be performed against a database without an "open and available" connection to it.

Connections are built by supplying an underlying driver or provider with a connection string, which is a way of addressing a specific database or server. ( Example: Server=sql_box;Database=Common;User ID=uid;Pwd=password; ) Once a connection has been built, it can be opened and closed at will, and properties ( such as the command timeout length, or transaction, if one exists ) can be set.

Many databases ( such as SQL Server 2000 ) only allow one operation at a time to be performed on a connection. In other words, if a request for data ( a SQL Select statement ) is sent to the database, and a result set is returned, the connection is open, but not available, until the client finishes consuming the result set. Other databases don't impose this limitation.

Pooling

Connection Pooling is a technology that was invented to improve performance of the client application and remove stress from the database server. Because connections are finite and expensive and can take a disproportionately long time to create, modern applications send a connection back to the pool when they finish with it, and take a connection from the pool when one is needed, if one is available.

This encourages the practice of opening a connection only when needed, and closing it as soon as the work is done, instead of an application holding a connection open during the entire course of its life. In this manner, a relatively small no.. of connections can service a large number of requests - often called multiplexing.

References

See also