Comparison between ODBC and JDBC, ODBCJDBC

Source: Internet
Author: User
Tags driver manager

Comparison between ODBC and JDBC, ODBCJDBC

In the process of learning J2EE JDBC, we immediately thought of ODBC when we first saw JDBC, and we can be sure that there is an inevitable relationship between them. When I started learning it, I still felt a little dizzy, so I checked a lot of information and compared it with the familiar ODBC.

First, we will briefly introduce ODBC and JDBC.

ODBC(Open Database Connectivity) is a set of standard APIs for Database access. These APIs use SQL to complete most tasks and support SQL languages and user-sent SQL. ODBC defines a set of specifications for accessing database APIs. These APIs are independent of DBMS and programming languages with different colors.

That is to say, an ODBC-based application does not rely on any DBMS for database operations and does not directly deal with DBMS. All database operations are completed by the corresponding dbms odbc driver. Both SQL Server, Access, and Oracle databases can be accessed using ODBC APIs.

It can be seen that the biggest advantage of ODBC isProcess all databases in a unified manner.

JDBCJava database Connectivity is an interface specification for Java and databases. JDBC defines a common low-level API that supports standard SQL functions. It consists of classes and interfaces written in Java, it is designed to allow 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.

 

In fact, JDBC and ODBC have moreCommonalities:

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

In terms of structure, the overall structure of JDBC is similar to that of ODBC, which has four components: application, driver manager, driver and data source. The working principle is also similar;

In terms of content interaction, JDBC maintains the basic features of ODBC and is independent from a specific database. It does not directly interact with the database, but uses the driver manager.

Between themDifferences:

We know that ODBC can connect almost all databases on almost all platforms. Why does Java not Use ODBC? The answer is: Java Can Use ODBC, but it is best to use in the form of a JDBC-ODBC bridge (Java connection is generally divided into Java direct connection and JDBC-ODBC bridge two forms ). So why JDBC? ODBC is not suitable for use directly in Java because it uses the C language interface. Calling local C code from Java has many disadvantages in terms of security, implementation, robustness, and automatic program portability. Literal Translation from odbc c api to Java API is not desirable. For example, Java does not have pointers, but ODBC is widely used for pointers (including the error-prone Pointer "void *"). In addition, ODBC is complex, while JDBC tries its best to ensure the simplicity of simple functions, and allows advanced functions when necessary. If you use ODBC, you must manually install the ODBC driver manager and driver on each client. If the JDBC driver is fully written in Java, the JDBC code can be automatically installed, ported, and secured on all Java platforms (from network computers to the mainframe. In short, JDBC has been developed based on ODBC to a large extent. JDBC retains the basic design features of ODBC. Therefore, programmers familiar with ODBC will find that JDBC is easy to use. The biggest difference between them is that JDBC is optimized based on the Java style and advantages, making it easier to use.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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.