Differences between odbc and jdbc in Databases

Source: Internet
Author: User
Tags driver manager
From: web.tongji.edu.cn ~ Yangdydatabasepaper6.htmJDBC and ODBC Peng Xin Li Long return ---- Heterogeneous Database System is a database system composed of multiple heterogeneous member database systems, heterogeneity is reflected in the differences between member databases in terms of hardware platforms, operating systems, and database management systems. ---- In

From: http://web.tongji.edu.cn /~ Yangdy/database/paper6.htm JDBC and ODBC class Peng Xin Li Long return ---- Heterogeneous database System is a database system composed of multiple heterogeneous member database systems, heterogeneity is reflected in the differences between member databases in terms of hardware platforms, operating systems, and database management systems. ---- In

From: http://web.tongji.edu.cn /~ Yangdy/database/paper6.htm

JDBC and ODBC · ban pengxin Lilong ·


---- A heterogeneous database system is a database system composed of multiple heterogeneous member database systems. Its Heterogeneity is reflected in the differences between member databases in terms of hardware platforms, operating systems, or database management systems.

---- A large amount of information on the Internet can be effectively managed only through the database system. Due to historical reasons, many database systems on the Internet are heterogeneous. To query and use heterogeneous databases in an Internet environment, a unified programming interface independent of a specific database management system must be provided.

---- Currently, many database systems support SQL. for Heterogeneous Database Systems Composed of SQL databases, JDBC and ODBC provide a unified way to access their heterogeneous members, it also lays the foundation for collaboration among heterogeneous members and operations on multiple members. This article briefly introduces the principle and application of JDBC and ODBC for unified access and collaboration between heterogeneous databases.



---- ODBC (Open DataBase Connectivity) is an application programming interface (API) proposed by Microsoft and widely accepted by the industry for DataBase access ), it is based on the call-level interface (CLI) specifications of X/Open and ISO/IEC, and uses Structured Query Language (SQL) as its database access language. ODBC has four components:

---- The application executes the processing and calls odbc api functions to submit SQL statements and retrieve results.

---- Driver Manager loads/uninstalls drivers based on application requirements, processes ODBC function calls, or transmits them to the Driver.

---- The driver processes ODBC function calls, submits SQL requests to a specified data source, and returns the results to the application. If necessary, the driver modifies an application request to make the request consistent with the syntax supported by the relevant DBMS.

---- Data sources include the data to be accessed by users and their related operating systems, DBMS, and network platforms used to access DBMS.

---- The use of ODBC drivers isolates applications from specific database calls. The driver manager centrally manages various drivers of a specific database, it also provides unified standard interfaces for applications, which lays the foundation for open ODBC.

---- Database independence

---- ODBC is designed for maximum interoperability and requires an application to use the same source code (without re-compilation or re-linking) to access different database management systems (DBMS.

---- ODBC defines a standard call layer interface (CLI ). This includes all functions in CLI specifications of X/Open and ISO/IEC and provides additional functions that are commonly required by applications. Each DBMS that supports ODBC needs different libraries or drivers, and the drivers implement functions in the odbc api. When you need to change the driver, the application does not need to re-compile or re-link, but dynamically loads the new driver and calls the function. To access multiple DBMS systems at the same time, the application can load multiple drivers. How to support drivers depends on the operating system. For example, in a Windows operating system, the driver is a dynamic link library (DLL ).

---- Using applications with the same source code to access different DBMS reflects the database independence of ODBC.

---- Support for special database functions

---- The standards and functions provided by various DBMS vary. How can an application use the unique functions of each DBMS with a unified interface?

---- On the one hand, ODBC defines public interfaces for all DBMS functions. These DBMS functions are more supported than most DBMS, but only require the driver to implement a subset of these functions. On the other hand, ODBC defines the API and SQL syntax consistency layer, which specifies the basic functions that the driver should support. ODBC also provides two functions (SQLGetInfo and SQLGetFunctions) to return general information about the driver and DBMS capabilities and a list of functions supported by the driver. Therefore, applications can check the special functions supported by DBMS.

---- In this way, when writing an application, you can check and automatically use the special functions supported by the DBMS corresponding to each driver. The advantage of this is that when you add the features supported by DBMS, the application does not need to change. You only need to install the updated driver, and the application can automatically discover and use these features.

---- Interoperability

---- You can access multiple DBMS systems at the same time by using multiple drivers. The Driver Manager provided by ODBC implements all ODBC functions, most of which are passed to the ODBC function in the Driver, statically linked to the application, or loaded when the application is running. In this way, the application calls the Driver ODBC function by name in the Driver Manager, instead of passing the pointer in each Driver. When an application needs to pass a specific driver, it first needs a connection handle that identifies the driver. Driver Manager loads the Driver and stores the function addresses in each Driver. To enable the Driver to call an ODBC function, the application can call the function in Driver Manager and send the connection handle to the Driver. Then, the Driver Manager calls the function using the previously stored address.

---- ODBC can be connected to multiple DBMS at the same time, solves the problem of simultaneously accessing multiple DBMS, and provides the ability to interoperate between heterogeneous member databases.



---- JDBC (Java DataBase Connectivity) is an interface specification for Java and databases. JDBC defines a general low-level application programming interface (API) that supports standard SQL functions ), it is composed of classes and interfaces written in the Java language. It aims to enable database developers to provide Java programmers with standard database APIs. The jdbc api defines several classes in Java, including database connection, SQL commands, result sets, and database metadata. It allows Java programmers to send SQL commands and process results. Through the driver manager, JDBC APIs can use different drivers to connect to different database systems.

---- Both JDBC and ODBC are SQL call-level interfaces based on X/Open. The design of JDBC follows ODBC ideologically and follows ODBC in its main abstraction and SQL CLI implementation, this makes JDBC easy to accept. The overall structure of JDBC is similar to ODBC. It also has four components: application, driver manager, driver and data source.

---- JDBC maintains the basic features of ODBC and is independent from specific databases. Applications with the same source code can access different DBMS by dynamically loading different JDBC drivers. When connecting different DBMS, each DBMS is identified only by different URLs. The DatabaseMetaData interface of JDBC provides a series of methods to check the DBMS's support for specific features and determine what features are available to support the features of specific databases. Like ODBC, JDBC also supports establishing multiple database connections in applications at the same time. With JDBC, it is easy to use SQL statements to access multiple heterogeneous databases at the same time, it lays the foundation for interoperability between heterogeneous databases.

---- However, JDBC not only has the aforementioned features of ODBC, but also supports hardware platform and operating system heterogeneity. This is mainly because ODBC uses the C language, while JDBC uses the Java language. The Java language has many advantages such as platform independence, portability, high security, good stability, distribution, and object-oriented. JDBC ensures the "100% pure Java" solution, using Java's platform independence, JDBC applications can naturally implement cross-platform features, making it more suitable for database applications in heterogeneous environments on the Internet.

---- In addition, The JDBC driver manager is built in, and the driver itself can be automatically downloaded through a Web browser without installation or configuration; the ODBC driver manager and ODBC driver must be installed and configured on each client separately.

Applications of JDBC and ODBC on the Internet


---- JDBC and ODBC provide good support for access to heterogeneous databases on the Internet because of their database independence or even platform independence.

---- Access to the database over the Internet is usually in the three-tier mode. Taking JDBC as an example, in the three-tier model, the client's Java Applet serves as the user interface. Instead of directly exchanging information with the database, it interacts with the application server through the custom application layer network protocol, the Application Server exchanges information with the database server through JDBC and implements the application logic. The JDBC and ODBC drivers of DM3 support the popular ASP and JSP Technologies, which allow both ODBC and JDBC to access multiple heterogeneous databases on the Internet at the same time.

---- ASP is a Web server-oriented technology. The client browser does not need any additional software support. ASP uses a script language such as VBScript. It embeds a program code in HTML code. the HTML code describes the display style of Information and the embedded program code describes the processing logic. In ASP, the VBScript Code is interpreted and executed by the ASP engine on the Web server. The execution result is re-embedded into the HTML code and sent to the browser together. The VBScript code can access multiple heterogeneous databases through ODBC.

---- JSP is a Web Development Technology Based on Java Servlet. It is very similar to ASP, but there is a difference: in JSP, the program code embedded in the HTML page is Java code; the program code embedded in the page is compiled into Servlet (this compilation operation only occurs when the first request to the JSP page) and executed by the Java Virtual Machine. Here, Java code can access multiple heterogeneous databases through JDBC, and its platform independence is particularly good. Currently, there are more and more database applications on the Internet, and JDBC and ODBC will play an important role in accessing heterogeneous databases on the Internet.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.