Database connection: Difference between revisions

Content deleted Content added
Dkennell (talk | contribs)
m grammar fix
Adding local short description: "Link between a client and database server", overriding Wikidata description "means by which a database server and its client software communicate with each other"
 
(19 intermediate revisions by 16 users not shown)
Line 1:
{{Short description|Link between a client and database server}}
{{no inline sources|date=July 2025}}
A '''Databasedatabase connection''' is a facility in [[computer science]] that allows [[Client (computing)|client]] software to talk to [[database server]] software, whether on the same machine or not. A '''connection''' is required to send [[command (computing)|commands]] and receive answers, usually in the form of a result set.
 
Connections are a key concept in [[data-centric]] programming. Since some DBMS engines require considerable time to connect, [[connection pooling]] was invented to improve performance. No command can be performed against a database without an "open and available" connection to it.
 
A '''Database connection''' is a facility in [[computer science]] that allows [[Client (computing)|client]] software to talk to [[database server]] software, whether on the same machine or not. A '''connection''' is required to send [[command (computing)|commands]] and receive answers, usually in the form of a result set.
 
Connections are a key concept in [[data-centric]] programming. Since some DBMS engines require considerable time to connect [[connection pooling]] was invented to 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 [[software driver|driver]] or [[data provider|provider]] with a [[connection string]], which is a way of addressing a specific [[database]] or [[server (computing)|server]] and instance as well as user authentication credentials (for 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 time-out length, or [[Database transaction|transaction]], if one exists) can be set. The Connection String is composed of a set of key/value pairs as dictated by the data access interface and data provider being used.
Line 11:
== Pooling ==
 
Database connections are finite and [[time complexity|expensive]] and can take a disproportionately long time to create relative to the operations performed on them. It is very inefficient for an application to create, use, and close a database connection whenever it needs to update a database.
 
[[Connection Poolpool]]ing is a technique designed to alleviate this problem. A pool of database connections can be created and then shared among the applications that need to access the database. When an application needs database access, it requests a connection from the pool. When it is finished, it returns the connection to the pool, where it becomes available for use by other applications.
 
The connection object obtained from the connection pool is often a wrapper around the actual database connection. The wrapper understands its relationship with the pool, and hides the details of the pool from the application. For example, the wrapper object can implement a "close" method that can be called just like the "close" method on the database connection. Unlike the method on the database connection, the method on the wrapper may not actually close the database connection, but instead return it to the pool. The application need not be aware of the connection pooling when it calls the methods on the wrapper object.
Line 21:
In a client/server architecture, on the other hand, a persistent connection is typically used so that server state can be managed. This "state" includes server-side cursors, temporary products, connection-specific functional settings, and so on.
 
An application failure occurs when the connection pool overflows. This can occur if all of the connectionconnections in the pool are in use when an application requests a connection. For example, the application may use a connection for too long when too many clients attempt to access the web site or one or more operations are blocked or simply inefficient.
 
== See also ==
* [[Open Database Connectivity]]
* [[ActiveX Data Objects|ADO]]
* [[ADO.NET]]
* [[ODBC|ODBC (Open Database Connectivity)]]
* [[JDBC]]
* [[RDBMS]]
Line 34 ⟶ 33:
 
* [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataidbconnectionclasstopic.asp IDbConnection Interface on MSDN]
* [https://web.archive.org/web/20080428080316/http://betav.com/blog/billva/2007/05/managing_and_monitoring_net_co.html Managing and Monitoring .NET Connections whitepaper.]
* [https://web.archive.org/web/20080501014734/http://betav.com/blog/billva/2006/06/getting_and_staying_connected_1.html Getting and Staying Connected whitepaper.]
* Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) Addison Wesley, William Vaughn, {{ISBN|978-0321243621}}
 
Line 42 ⟶ 41:
 
[[Category:Databases]]
 
 
{{database-stub}}