All Topics  
Database connection

 

   Email Print
   Bookmark   Link






 

Database connection



 
 
A Database connection is facility in computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
 that allows client
Client (computing)

A client is an Application software or system that accesses a remote service on another computer system, known as a Server , by way of a Computer network....
 software to talk to database server
Database server

A database server is a computer program that provides database services to other computer programs or computers, as defined by the client-server software modeling....
 software, whether 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. Since some DBMS engines require considerable time to connect connection pooling was invented to improve performance.






Discussion
Ask a question about 'Database connection'
Start a new discussion about 'Database connection'
Answer questions from other users
Full Discussion Forum



Encyclopedia


A Database connection is facility in computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
 that allows client
Client (computing)

A client is an Application software or system that accesses a remote service on another computer system, known as a Server , by way of a Computer network....
 software to talk to database server
Database server

A database server is a computer program that provides database services to other computer programs or computers, as defined by the client-server software modeling....
 software, whether 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. 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 driver or provider
Provider

The provider model is a design pattern formulated by Microsoft for use in the ASP.NET Starter Kits and formalized in .NET version 2.0. It is used to allow an application to choose from one of multiple implementations in the application configuration, for example, to provide access to different data stores to retrieve login information, or to...
 with a connection string
Connection string

In computing, a connection string is a String that specifies information about a data source and the means of connecting to it. It is passed in code to an underlying software driver or provider in order to initiate the connection....
, which is a way of addressing a specific database
Database

A database is a structured collection of records or data that is stored in a computer system. The structure is achieved by organizing the data according to a database model....
 or server
Server (computing)

A server is a computer program that provides services to other computer programs , in the same or other computer. The physical computer that runs a server program is also often referred to as 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 transaction
Transaction

A transaction is an agreement, communication, or movement carried out between separate entities or objects, often involving the exchange of items of value, such as information, goods, services and money....
, 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.

Many databases (such as PostgreSQL
PostgreSQL

PostgreSQL is an object-relational database management system . It is released under a BSD licenses and is thus free software. As with many other open-source programs, PostgreSQL is not controlled by any single company, but has a global community of developers and companies to develop it....
) only allow one operation to be performed at a time on each connection. If a request for data (a SQL
SQL

SQL is a database computer language designed for the retrieval and management of data in relational database management systems , database schema creation and modification, and database object access control management....
 Select
Select (SQL)

The SQL SELECT statement returns a result set of records from one or more tables.It retrieves zero or more rows from one or more base tables, temporary tables, or views in a database....
 statement) is sent to the database and a result set is returned, the connection is open but not available for other operations until the client finishes consuming the result set. Other databases, like SQL Server 2005
Microsoft SQL Server

Microsoft SQL Server is a relational database management system produced by Microsoft. Its primary query languages are SQL and Transact-SQL....
 (and later), do not impose this limitation. However, databases that provide multiple operations per connection usually incur far more overhead than those that permit only a single operation task at a time.

Pooling


Database connections are finite
Finite

Finite is the opposite of infinite. It may refer to:* Having a finite number of elements: finite set* Being a finite number, so not equal to ; all real numbers are finite...
 and 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 and close a database connection whenever it needs to update a database.

Connection Pool
Connection Pool

In software engineering,a connection pool is a cache of database connections maintained by the database so that the connections can be reused when the database receives future requests for data....
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.

This approach encourages the practice of opening a connection in an application only when needed, and closing it as soon as the work is done, rather than holding a connection open for the entire life of the application. In this manner, a relatively small number of connections can service a large number of requests. This is also called multiplexing
Multiplexing

In telecommunications and computer networks, multiplexing is a process where multiple analog message signals or digital data streams are combined into one signal over a shared medium....
.

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 connection 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
    Open Database Connectivity

    In computing, Open Database Connectivity provides a standard software application programming interface method for using database management systems ....
  • ADO
    ActiveX Data Objects

    Microsoft's ActiveX Data Objects is a set of Component Object Model object s for accessing data sources. It provides a Abstraction layer between programming languages and OLE DB ....
  • ADO.NET
    ADO.NET

    ADO.NET is a set of computer software components that can be used by programmers to access data and data services. It is a part of the base class library that is included with the .NET Framework....
  • ODBC
  • JDBC
  • RDBMS