370 likes | 1.06k Views
Open DataBase Connectivity a standard database access method developed by Microsoft to access data from any application regardless of which database management system (DBMS) is handling the data. ODBC middle layer- between an application and the DBMS.
E N D
Open DataBase Connectivity a standard database access method developed by Microsoft to access data from any application regardless of which database management system (DBMS) is handling the data. ODBC middle layer- between an application and the DBMS. Translates the application's data queries into commands that the DBMS understands. Both the application and the DBMS must be ODBC-compliant – the application must be capable of issuing ODBC commands and the DBMS must be capable of responding to them. Central role for SQL ODBC
In addition to the ODBC software, a separate module or driver is needed for each database to be accessed. Driver Each database management system needs a specific ODBC driver. A driver is a program that interacts with a particular device or special kind of software e.g DBMS. The driver contains the special knowledge of the device or special software interface that programs using the driver do not. A driver is often packaged as a dynamic link library (DLL, EXE or VXD) file. -a small program, which can be called by a program and executed when needed
ODBC is based on SQL Call-Level Interface standard. It allows programs to use SQL requests that will access databases without having to know the proprietary interfaces to the databases. ODBC handles the SQL request and converts it into a request the individual database system understands. In the distributed object architecture, Common Object Request Broker Architecture (CORBA), the Persistent Object Service (POS) is a superset of both the Call-Level Interface and ODBC. Java Database Connectivity (JDBC), used by Java to reach ODBC-accessible databases.
The ODBC architecture has four components: · Application. Performs processing and calls ODBC functions to submit SQL statements and retrieve results. · Driver Manager. Loads and unloads drivers on behalf of an application. Processes ODBC function calls or passes them to a driver. · Driver. Processes ODBC function calls, submits SQL requests to a specific data source, and returns results to the application. If necessary, the driver modifies an application's request so that the request conforms to syntax supported by the associated DBMS. · Data source. Consists of the data the user wants to access and its associated operating system, DBMS, and network platform (if any) used to access the DBMS.
Multiple drivers and data sources can exist, which allows the application to simultaneously access data from more than one data source. • The ODBC Application Program Interface is used in two places: • between the application and the Driver Manager, • and between the Driver Manager and each driver. • The interface between a Driver Manager and drivers is sometimes referred to as the service provider interface, or SPI. • For ODBC, the application programming interface (API) and the service provider interface (SPI) are the same;
OLE DB and ODBC are Application Program Interfaces that provide access to a range of data sources. e.g. enables a single Visualbasic program to use data from many different databases, maybe from different suppliers. Microsoft designed ODBC to access SQL data and OLE DB to access any type of data. OLE DB has evolved from ODBC. The difference is in the surrounding context and in the generalization of a few main terms; OLE DB
Commonly used terms and what they mean in ODBC and OLE DB. Data source ODBC-A relational DBMS OLE DB-A module that wraps a data store and exposes its content as a set of rows and columns Table ODBC- A table in a relational database OLE DB- An aggregation of related rows and homogeneous columns
Result set A chunk of client memory that holds a set of records An independent and stand-alone module that exposes a set of records Command A SQL command interpreted by the connected DBMS A text string that the data source can understand
OLE DB accesses all types of information—relational and non-relational, flat and hierarchical, persistent and volatile, based on SQL or on any other query language. Components, called data providers, ‘wrap’ (or encapsulate) a data store. This makes the data store a kind of ‘black box’. Programs that use the data stores do not need to know the internal workings of the data store. They only need to know the detail of the interface to the data store-this is standardised through OLE DB.
The application that accesses the data is called a data consumer e.g. Access 2000, Visual Basic program The program that enables native access to the data is called a database provider e.g. Microsoft OLE DB Provider for SQL Server or Microsoft Jet 4.0 OLE DB Provider .This will be database specific I.e. there will need to be a different data provider for every database. A data link is the connection information that a data consumer uses to access a data source through the OLE DB provider of that data source. Consumer e.g. VB program Link Provider e.g. Oracle, SQL Server
Data Link file Typically connect to an OLE DB provider from Microsoft Access using the Data Link Properties dialog box, Can also define connection information for an OLE DB provider in a Microsoft Data Link file (.udl) Microsoft Windows Explorer capable of creating the file(choose Microsoft Data Link from the New menu, create a Microsoft Data Link file, select the file name, right-click on the file name, and then choose Properties).
e.g. file content- a connection string Provider=SQLOLEDB.1; Persist Security Info=False; User ID=u878878; Initial Catalog=car_hireSQL; Data Source=scm-database
When connected to a data provider, a client application (data consumer) always receives a set of records, whether the data provider manages tables from a relational database management system (RDBMS), a directory listing, a text file or whatever. The data provider is responsible for retrieving the data from the physical source and formatting it. The data can reside on a persistent medium (disk files or databases), be kept in memory, or span various machines and platforms. It can be relational or hierarchical, structured or flat, written in a standard or a proprietary format, and accessible or inaccessible through ODBC.
In addition, the result set (called a rowset or a recordset) that OLE DB returns isn't a simple stream of bytes copied into the client application's memory, as with ODBC. It's a stream of data that a standardised module, with a separate programming interface, holds. In other words, the data returned is not simply data. It is data plus the means of manipulating the data –an object. The object is called a RecordSet. Such an object gives you several facilities for manipulating the recordset—sorting, filtering, and scrolling—and it enables concurrent access to the same data from multiple clients. You can set up the data rows to work even when they're disconnected from the data source.
OLE DB is a set of COM-based interfaces that expose data from a variety of sources. OLE DB interfaces provide applications with uniform access to data stored in diverse information sources, or data stores.
DSN • Data Source Name. • A Data Source Name provides connectivity to a database through an ODBC driver. • The DSN contains • database name • Directory • database driver • UserID • password, • and other information. • The DSN can be used by an application to call information from the database.
DSN is often used by Active Server Pages and Visual Basic programs when a database operation is necessary The DSN is a connection made by the ODBC server to a specified database. This connection is assigned a name which can be called by ASP (Active Server Pages), or other programming/scripting languages to manipulate the database. Acts as a Data Link. ASP is the consumer DSN is the link Database is the provider. In the following the term Data Source is the same as Data Link.
DSN vs DNS Important not to confuse DSN and DNS A Domain Name Server (DNS) is part of the distributed Internet directory service. A DNS is used to translate between domain names and IP addresses Most Internet services rely on a DNS to work If the DNS fails, web sites cannot be located and email delivery stalls.
Types of DSN • Three types of DSNs: • System DSN (machine data source) -- can be used by anyone who has access to the machine and services, such as Microsoft Windows NT services. DSN info is stored in the registry. • User DSN (machine data source) -- created for a specific user. Also stored in the registry. • File DSN -- DSN info is stored in a text file with .DSN extension
Machine Data Sources Machine data sources only useable on the computer they are defined on Machine data sources store connection information in the Windows Registry on a specific computer with a user-defined name. A machine data source provides added security, Cannot be copied by a remote user to another computer.
File Data Sources File data sources store connection information in a text file More flexible to use than machine data sources. A file data source can be copied to any computer with the correct ODBC driver
The file data source can be • placed on a single server, • shared between many computers on the network, • and the connection information easily maintained in one location. • e.g • [ODBC] • DRIVER=SQL Server • SERVER=scm-database(local) • WSID=I5X3L2 • DATABASE=bsc2
DSN-less connection Instead of using a DSN to connect to a database, the developer specifies the necessary information in the application. With a DSN-less connection the developer is free to use connection standards other than ODBC, such as OLE DB.
ODBC Data Source Administrator The ODBC Data Source Administrator used to add and configure data sources The ODBC Administrator updates data source connection information. As data sources added the ODBC Administrator updates the registry information.
Summary • Application programs can be written and configured so that they can access any source of data (database, file, data stream, directory…..etc) i.e. are physically independent from data sources. • Microsoft standard to achieve this is OLE DB. • Other suppliers use system software (middleware) with a similar architecture e.g. OMG/CORBA. • Programs connect to data sources and receive data in the form of objects (record sets) • Connections are established by defining Data Links.