• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
aggie.doc.doc
 

aggie.doc.doc

on

  • 708 views

 

Statistics

Views

Total Views
708
Views on SlideShare
708
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    aggie.doc.doc aggie.doc.doc Document Transcript

    • ODBC and JDBC Aggie Hoversten CSCI 397-16 Fall 1999
    • Table of Contents: ODBC and JDBC............................................................................................................................1 Aggie Hoversten..............................................................................................................................1 CSCI 397-16....................................................................................................................................1 Fall 1999.........................................................................................................................................1 WHY THE NEED FOR ODBC/JDBC?........................................................................................3 INTRODUCTION TO ODBC........................................................................................................4 ODBC ARCHITECTURE..............................................................................................................4 EXAMPLE OF ODBC...................................................................................................................6 INTRODUCTION TO JDBC.........................................................................................................6 JDBC ARCHITECTURE...............................................................................................................7 ODBC VERSUS JDBC..................................................................................................................8 SUMMARY.....................................................................................................................................9 INDEX..........................................................................................................................................11 REFERENCES.............................................................................................................................12 2
    • WHY THE NEED FOR ODBC/JDBC? Companies have always had a need to store information. Databases were created to store this information in a way that was easy to access and manipulate. With the increase growth of the computer industry and the availability of so many different types of hardware and software, company data can now be stored on many different Database Management Systems (DBMS) and operating systems. Access to multiple DMBSs can become complicated for the user and for businesses. The introduction of client/server computing created a need to find the most efficient use for all computer resources. The client machine gives users a graphical front-end application running on a desktop computer that is capable of accessing data from a server on the back-end. The server hosts the DBMS on a more powerful machine and provides a more central location for data storage. Open DataBase Connectivity (ODBC) and Java DataBase Connectivity (JDBC) were created to allow users and developers a way to efficiently access the data residing on a server or many different servers using their client machine. “ODBC (or JDBC) defines a method of connecting to data sources (or databases) that are open to as many applications and data sources as possible.” (Whiting, 1996, p.5) To communicate with the server, the application needs to use some type of middleware to connect the client to the database. ODBC or JDBC takes Structured Query Language (SQL) statements from the client machine and formats them in a way the database server can understand. (Nance, P.2) Thus, allowing a user to open an application on a client machine that interacts with a database either on his machine or on a server located elsewhere. 3
    • INTRODUCTION TO ODBC ODBC is an application programming interface (API) allowing an application to interact with any type of relational database residing on any operating system. “Microsoft created ODBC in 1992 based on the call level interface (CLI) specifications from X/Open and the SQL Access Group (SAG).” (Whiting, 1996, p.18) Computer programs written in Visual Basic, C, C++, Pascal, COBOL and many other languages use ODBC to perform database operations on databases such as Oracle, IBM’s DB2, and Microsoft’s SQL Server. (Nance, Network Computing, P.2) Businesses can continue to use their current client application and access information from many different DBMS, allowing for a more economical and easier method of sharing information. ODBC ARCHITECTURE There are four components to describe the ODBC architecture: 1) the client application, 2) the ODBC Driver Manager, 3) the ODBC Drivers and, 4) the data source. 1. The client application calls the ODBC API functions to connect to a data source, submits SQL statements, retrieves results, and disconnects from a data source. There are many applications, but most fall into one of three categories: generic, vertical, and custom. Generic applications are software packages that can be purchased in a typical computer department/store. They can work with a single or multiple DBMSs and “…are highly interoperable among DBMSs and they need to use ODBC in a relatively generic manner.” (“Microsoft ODBC 3.0 Programmer’s Reference - Volume 1,” p.34) Vertical applications are programs that do a single task such as an order entry program for a catalog company. The order entry program can use a specific DBMS for 4
    • a small company, but may use a different DBMS for a large company. The program is independent from the database that is used. Custom applications usually provide one specific task for one specific organization. “For example, an application in a large company might gather sales data from several divisions (each of which uses a different DBMS) and create a single report.” (“Microsoft ODBC 3.0 Programmer’s Reference - Volume 1,” p.34) The program is written specifically for a particular driver and DBMS. 2. The ODBC driver manager loads the appropriate ODBC drivers dynamically as they are needed. It processes ODBC function calls, or it passes these requests to a driver and returns information/results to the client application. 3. The ODBC Drivers connect to the data source, process the ODBC function calls, submit SQL requests to a specific data source (or relational database), translate ODBC SQL to DBMS-specific SQL (i.e. by replacing escape clauses defined by ODBC with DBMS-specific SQL), and send and retrieve data to and from the data source. 4. The data source is comprised of data on a DBMS (ie. Oracle, DB2, SQL Server) and resides on a specific operating system (ie. Windows NT, Unix, MacIntosh). (“Microsoft ODBC 3.0 Programmer’s Reference - Volume 1,” p.34) The ODBC architecture allows the client to use the same function call to access any one of the different data source(s). 5
    • EXAMPLE OF ODBC1 A human resource (HR) department in a large company has access to many different DBMSs. On the HR computer network is a Microsoft NT server running SQL Server. This database stores all the information about each employee. The HR department can also connect to a database maintained by the company’s health care insurance company to access information regarding the employee’s health benefits. The database located at the insurance company runs DB2 on an IBM mainframe. The HR department is also connected to the financial institution in charge of the company’s 401K retirement plan. All information on this system resides in Oracle running on Unix. These multiple DBMS connections are made possible by ODBC. The processes needed to retrieve the necessary information from the different DBMSs are handled by ODBC and are transparent to the HR department. INTRODUCTION TO JDBC “JDBC is a Java API for executing SQL statements. JDBC was developed by Sun Microsystems in 1996 to allow programs written in Java to issue SQL statements and access information on a DBMS. An interesting side note, JDBC is often thought of as ‘Java DataBase Connectivity,’ however, it is actually a trademark name and not an acronym.” (Hamilton, 1997, Ch. 1) Similar to ODBC, it is easy to send SQL statements to any relational database using JDBC. JDBC consists of a set of classes and interfaces written in the Java programming language, and provides a standard API for tool/database developers making it possible to write database applications using pure Java API. For example, a developer does not have to write one program to access a Sybase database, and another program to access an Oracle database. (Hamilton, 1997, Ch. 1) 1 Modeled the Human Resource Department at DST Innovis, Inc. < http://www.dstinnovis.com/main.htm> 6
    • JDBC ARCHITECTURE The JDBC architecture is very similar to ODBC’s architecture. There is the Java client application, the JDBC driver manager, the JDBC drivers, and the data source or DBMS. All four layers work the same as ODBC, however, JDBC does concentrate more on the drivers layer. Often there is reference to the “JDBC Driver Quartet.” (Joch, BYTE Magazine, May 1998, P. 112N) This reference exists because JDBC consists of four types of standard drivers that are critical in what the client will use to connect and communicate with the database. Driver Type 1 is the JDBC-ODBC bridge that provides JDBC connectivity via ODBC drivers. Using ODBC drivers allow JDBC to be introduce into the market quickly. JDBC communicates with the ODBC layer that in turn communicates with the database. Today, the JDBC-ODBC bridge is still used to access some DBMSs that do not have JDBC drivers implemented. This extra layer decreases efficiency, but performes the necessary functions. Another drawback of Type 1 is that ODBC code and database client code must be loaded on every client machine that uses the JDBC-ODBC bridge. An example of this driver type is a company with a three-tier architecture network. The company’s application, written in Java, access a middle tier where the JDBC-ODBC bridge resides, and the middle tier in turn interacts with a separate DBMS on another machine. (Joch, BYTE Magazine, May 1998, P. 112N) Driver Type 2 is known as “Native API, partly Java Driver.” This JDBC driver is written partly in Java and partly in native code. This driver type “converts JDBC calls into calls on the client API for Oracle, Informix, DB2, and other DBMS. It does not require ODBC, however, native code will need to be installed on the client machine. This driver type is best for companies using a specific DBMS due to some unique characteristic available with that 7
    • particular DBMS. (Joch, BYTE Magazine, May 1998, P. 112N) It is also a good driver for two- tier applications. Driver Type 3 is the Net Protocol, Pure Java driver. The JDBC driver is written completely in Java and “translates JDBC calls into a DBMS-independent network protocol that is then translated into a DBMS protocol by a server.” (Joch, BYTE Magazine, May 1998, P. 112N) This is very flexible and is used mainly when serving public users such as Web users. For example, a developer can use Java and the JDBC API to publish a web page containing and applet that retrieves its information from some remote database. Driver Type 4 uses the Native Protocol, Pure Java concept, however, this driver uses the vendor specific/proprietary protocol to communicate directly with DBMS. Again, the JDBC driver is written completely in Java. (Joch, BYTE Magazine, May 1998, P. 112N) This is the best way to serve many users from a single server. A large corporation with employees on client machines in different locations using the intranet to access their personal file via JDBC would use a Type 4 driver. A list of the latest drivers available for all the different “JDBC Driver Quartet” can be found at http://java.sun.com/products/jdbc/drivers.html. ODBC VERSUS JDBC2 ODBC PROS:  Its performance is highly efficient.  Does not require excessive memory.  Programs written in Visual Basic, C, C++, Pascal, and many other programming languages can perform database operations via ODBC. 2 Most of the pros and cons were found on the Microsoft and JavaSoft web pages, and various books listed on the references page at the end. 8
    •  There are ODBC database drivers currently available for 55 of the most popular databases.  “Microsoft’s ODBC API is probably the most widely used programming interface for accessing relational databases.” (Hamilton, 1997, Ch.1)  There are more than 170 application programs using ODBC. ``ODBC is not going away,'' says Brian Reed, product manager at Intersolv. ``It's the market standard ...'' (Richter, BYTE Magazine, November 1994) ODBC CONS:  Difficult to learn and code.  ODBC has few commands with many complex options.  ODBC drivers need to be installed on every client machine needing DBMS access. JDBC PROS:  Java methods are simple and intuitive.  The code is easier to learn and program.  When the JDBC driver is written all in Java, JDBC code is automatically installable (or downloaded to a users machine quickly),  Portable (can run on any type of machine or operating system) and secure. JDBC CONS:  JDBC is only for programs written in Java. SUMMARY As can be seen from the ODBC and JDBC pros and cons listed above, there are more pros than cons for both middleware discussed. ODBC is already a standard for networks with one or more DBMSs, and JDBC is beginning to catch up quickly as more and more companies write software to utilize it. The architecture of both middleware is straightforward and allows an 9
    • application on a client machine to interact with a DBMS. In addition, developers are no longer restricted in building applications targeted for a specific database. The creation of ODBC and JDBC not only allow users and businesses more power over their DBMS, but also gives the users a variety of choices to make when implementing a DBMS architecture to fit their needs. 10
    • INDEX  SAG (SQL Access Group): an organization of leading hardware and software developers committed to universal database access. They set up conformance level standards that ODBC needs to meet such as: levels 0, 1, and 2 for the API; minimum, core, and extended for the SQL Grammar. (Richter, BYTE Magazine, November 1994)  API (Application Programming Interface): contains calls made by the application. These interfaces (embedded SQL, SQL modules, and call-level interfaces) are generally specific to each DBMS, although they are usually based on an ANSI or ISO standard. (“Microsoft ODBC 3.0 Programmer’s Reference, p.27)  ANSI (American National Standards Institute): is the primary organization for fostering the development of technology standards in the United States. (<http://www.ansi.org>)  ISO (International Organization for Standardization ), founded in 1946, is a worldwide federation of national standards bodies from some 100 countries, one from each country. (<http://www.whatis.com>)  Intersolv, Inc. in Rockville, Md.: one of the first companies to ship the ODBC driver manager. JavaSoft, asked Intersolv to create ODBC Bridge. (<http://www.intersolv.com>)  X/Open: The Open Group is committed to delivering greater business efficiency by bringing together buyers and suppliers of information systems to lower the time, cost and risk associated with integrating new technology across the enterprise. (<http://www.opengroup.org>)  Native code: code written in another, specific language. Used when the code already has the necessary capabilities that would be too difficult to rewrite, or when maximizing speed is a necessity. (Horstmann, 1998, p.579)  Protocol: the special set of rules for communicating that the end points in a telecommunication connection use when they send signals back and forth. TCP/IP HTTP, FTP, and NETBEUI. (<http://www.whatis.com>) 11
    • REFERENCES Hamilton, Graham, Cattell, Rick and Fisher, Maydene. “JDBC Database Access with Java: A Tutorial and Annotated Reference.” Addison-Wesley Pub Co, 1997. <http://java.sun.com/docs/books/jdbc/intro.html> Joch, Alan. “JDBC’s Growing Pains.” BYTE Magazine, May 1998 v23 n5: 112M-P. Horstmann, Cay, and Cornell, Gary. “Core Java 1.1: Volume II – Advanced Features.” Palo Alto, CA: Sun Microsystems Press, 1998. Nance, Barry. “Data Access Via ODBC and JDBC.” Network Computing. <http://www.networkcomputing.com/netdesign/odbc2.html> Richter, Jane. “ODBC 2.0 Further Establishes Cross-Product Data Sharing Standard.” BYTE Magazine, November 1994. <http://www.byte.com/art/9411/sec4/art15.htm> Whiting, Bill, Morgan, Bryan, and Perkins, Jeff. “Teach Yourself ODBC Programming In 21 Days.” Indianapolis, IN: Sams Publishing, 1996. “JDBC™ Data Access API.” JavaSoft Corporation, 3 November 1999. Palo Alto, CA <http://java.sun.com/products/jdbc/index.html> “JDBC™ Technology Guide: Getting Started.” JavaSoft Corporation, 6 October 1999. Palo Alto, CA < http://java.sun.com/products/jdk/1.3/docs/guide/jdbc/getstart/GettingStartedTOC.fm.html > “Open Database Connectivity (ODBC) for Database Connectivity.” Microsoft Corporation, 1999. Redmond, WA <http://www.microsoft.com/data/odbc/wpapers/odbcnole.htm> “Welcome to the ODBC Section of the Microsoft Universal Data Access Web Site.” Microsoft Corporation. 17 March 1999. Redmond, WA <http://www.microsoft.com/data/odbc/> 12