On JDBC and ODBC

Source: Internet
Author: User
Tags driver manager odbc

In the JDBC process of learning the Java EE, the first to see JDBC immediately associated with ODBC, and we can be sure that they have a certain relationship. Start to learn it still feel a little dizzy, so I looked at a lot of data, and more familiar with the ODBC to compare.

Let's take a brief look at ODBC and JDBC.

ODBC (Open database Connectivity) is a set of standard APIs for database access that do most of the work through SQL, and it natively supports the SQL language to support the SQL that the user sends. ODBC defines a set of specifications that access the database APIs that are independent of the different DBMS and programming languages of actual performance.

That is, an ODBC-based application that operates on a database that does not rely on any DBMS, does not interact directly with the DBMS, and that all database operations are done by the corresponding DBMS's ODBC driver. Both SQL Server, Access, and Oracle databases can be accessed using the ODBC API.

Thus, the greatest advantage of ODBC is the ability to handle all databases in a unified manner.

JDBC (javadatabase Connectivity) is the interface specification for Java and database, and JDBC defines a generic low-level API that supports standard SQL functionality, which consists of classes and interfaces written in the Java language. Designed to allow database developers to provide standard database APIs for Java programmers.

The JDBC API defines a number of classes in Java that represent database connections, SQL directives, result sets, database metadata, and so on. It allows Java programmers to send SQL instructions and process the results.

In fact, JDBC and ODBC generally have more in common:

For example,JDBC and ODBC are X/open-based SQL call-level interfaces;

structurally, the overall structure of JDBC is similar to ODBC, and there are four components: application, Driver Manager, driver and data source, and the working principle is basically the same;

In terms of content interaction, JDBC maintains the basic nature of ODBC and is independent of a particular database . And not directly interacting with the database, but through the driver manager.

the difference between them:

We know that ODBC can connect almost all of the databases on almost all platforms. Why doesn't Java use ODBC? The answer is: Java can use ODBC, but preferably in the form of Jdbc-odbc Bridge (Java connection is generally divided into two forms of Java direct and Jdbc-odbc Bridge). Then why do we need JDBC? Because ODBC is not intended to be used directly in Java, it uses the C language interface. Calling local C code from Java has many drawbacks in terms of security, implementation, robustness, and automatic portability of programs. Literal translation from the ODBC C API to the Java API is undesirable. For example, Java does not have pointers, but ODBC has a wide range of pointers (including a very error-prone pointer "void *"). In addition, ODBC is more complex, while JDBC tries to ensure simplicity of simple functionality while allowing advanced functionality when necessary. If you use ODBC, you must manually install the ODBC Driver Manager and drivers on each client computer. If you write the JDBC driver completely in Java, the JDBC code can be automatically installed, ported, and secured on all Java platforms, from network computers to mainframes. In short, JDBC is largely based on the ODBC, developed from his foundation. JDBC retains the basic design features of ODBC, so programmers familiar with ODBC will find JDBC very easy to use. The biggest difference between them is that JDBC is based on Java style and benefits and is optimized for ease of use. Turn from 46685951

On JDBC and ODBC

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.