ODBC and JDBC

Source: Internet
Author: User
Tags dbase driver manager sybase database
Yesterday I told you how to connect to the ACCESS database through JDBC. Someone asked me what JDBC is .. I ...... so let's talk about JDBC today. By the way, let's talk about ODBC. You just need to look for something like this concept or principle on the Internet. Unlike code, many websites require you to register, pay, and so on. After searching for half a day, I only found that one or two articles are better, so I borrowed some articles, but JDBC does not seem to be good, I had to look at the original English documents by myself. I found that many articles on the Internet only translated part of the JDBC chapter in <core Java> (Volume 2, articles from all over the world are generally copied. However, if you do not understand the suspicion of misleading people, I will feel a little uncomfortable, you can find that many good articles such as Java basics and swing on the Internet Reference <core Java> volume 1. As for JDBC, java multithreading or other things are less, because <core Java> the second volume does not have a Chinese version, and I always think this is strange, this book has been out for a long time (it is indeed a good book), Why translate the first and second volumes without translation !! It's a bit incredible. 1. ODBC (1 ). the concept of ODBC (Open Database Connectivity, Open Database interconnection) is a component of the database in Microsoft's wosa (windows open services architecture, it establishes a set of specifications and provides a set of standard APIs for database access (application programming interfaces ). These APIs use SQL to complete most of their tasks. ODBC also provides support for the SQL language. You can directly send SQL statements to ODBC.

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. That is to say, both FoxPro, access, and Oracle databases can be accessed using ODBC APIs. It can be seen that the biggest advantage of ODBC is that it can process all databases in a unified way (2). ODBC structure 1. application ).

2. ODBC Manager (administrator ). The program is located in 32-bit ODBC on Windows 95 control panel. Its main task is to manage the installed ODBC driver and manage the data source.

3. Driver manager ). The driver manager is included in odbc32.dll and transparent to users. Its task is to manage ODBC drivers and is the most important component in ODBC.

4. odbc api.

5. ODBC driver. Is a DLL that provides interfaces between ODBC and databases.

6. data source. The data source contains information such as the database location and database type, which is actually an abstraction of data connection.

To access a database, an application must first register a data source using the ODBC Manager. The manager registers a data source based on the database location, database type, ODBC driver, and other information provided by the data source, establish a connection between ODBC and a specific database. In this way, as long as the application provides the data source name to ODBC, ODBC can establish a connection with the corresponding database.

In ODBC, ODBC APIs cannot directly access the database and must exchange information with the database through the driver manager. The driver manager is responsible for passing the application's odbc api call to the correct driver. After the driver completes the corresponding operation, return the result to the application through the driver manager.

The ODBC driver is required to access the ODBC data source. You can use visual c ++ 5.0 to install drivers such as SQL Server, access, paradox, dBase, Foxpro, Excel, Oracle, and Microsoft text. by default, vc5.0 only installs drivers for SQL Server, access, Foxpro, and DBASE. if you need to install another driver, you need to re-run the installation program of VC 5.0 and select the required driver. Note: By the way, Microsoft is now implementing ADO database access. As for ado, let's talk about VC ++ next time. 2. JDBC (1 ). the concept of JDBC is a Java API that executes SQL statements. JDBC is a trademark of a product, but it can also be viewed as "ja
VA database conneci.pdf (Java database connection )". It consists of a group of classes and interfaces written in Java.
JDBC has become a standard API for tools/database developers. You can use pure Java APIs to compile databases.
Application.
With JDBC, you can easily transmit SQL statements to any relational database. In other words, the user does not have
Write a program for the Sybase Database and write another program for accessing the Oracle database. You can use the jdbc api to write the unique
A program that sends SQL statements to any database. The combination of Java and JDBC enables programmers
After writing the database application software only once, it can run on various database systems. Java is robust,
Secure, easy to use, easy to understand, and automatically download to the network. Therefore, it is an excellent basic language for database applications.
Statement. Now we need to find a way to make Java applications talk to different databases, and JDBC is just implementing this
A mechanism.
JDBC expands the application scope of Java. For example, you can use Java and JDBC APIs to publish a message containing remote databases.
The web page of the applet. With JDBC, enterprises can connect all their employee information to one or
Multiple internal databases. Without a doubt, as Java programmers continue to increase, the more requests for accessing Java Databases
More urgent. The MIS administrator wants to combine Java with JDBC because it helps to publish enterprise information more easily and economically.
The business community can constantly use installed databases to facilitate access to information without having to consider what dBm databases are
Stored in the S system. It can shorten the development time of new applications and greatly simplify the installation and Version Control of databases.
Once the programmer writes or updates the application and puts it on the server, everyone can get the latest version.
. In the commercial sales information service field, Java and JDBC can better provide external customers with the latest information (2). Structure

(3). functions and features

Function:

· Establish a connection with the database.
· Send SQL statements.
· Processing result

Features:

JDBC is the foundation of low-level APIs and advanced APIs
JDBC is a "low-level" interface, because it directly calls SQL commands, but it can be used to construct high-level interfaces and
. An advanced interface is a "user-friendly" API that is easier to understand and more convenient. It is translated into a jdb
C. Two JDBC-based advanced APIs are under development:
One is Java That embeds SQL. JDBC requires that the SQL statement be passed as a string to the Java method. Embedded SQL pre-processing
Program, allowing programmers to directly mix SQL and Java. For example, you can receive or provide Java variables in SQL statements.
SQL value. Embed the SQL Preprocessing Program and translate the mixed Java/SQL into Java with JDBC calls.
Another is to map relational database tables directly into Java classes. In the ing of "Object/Link", each row in the table changes
A class instance. The values in each column correspond to an attribute of the instance. Then the programmer can directly operate the Java object and
An SQL call for data retrieval and storage is automatically generated. In addition, it provides more advanced ing, for example
Combine rows

 

3. JDBC and ODBC

Comparison between JDBC, ODBC, and other APIs
Currently, Microsoft ODBC APIs are the most widely used programming interfaces for accessing relational databases.
All databases on the platform are connected. The question is, can I use ODBC through Java? The answer is yes,
The best practice is to use JDBC-ODBC bridging with the help of JDBC. The reasons for JDBC are as follows:
(1) ODBC cannot be used directly in Java. Because ODBC uses the C language interface, if Java is used to call the C code of the local machine
It will bring difficulties in security, attributes, robustness, and application portability.
(2) You do not want to translate odbc c APIs into Java APIs literally. For example, ODBC uses a large number of error-prone
Java removes this unsafe pointer. Now, through JDBC, ODBC is translated into Java-style object-oriented
.
(3) ODBC is hard to learn. ODBC blends simple functions with advanced functions, and even simple queries bring
Complex options. The Design of JDBC makes simple things easy to use, so that users can only use advanced
Function.
(4) JDBC Java APIs provide "pure Java" solutions. When ODBC is used, the ODBC driver administrator and the drive
The animation must be manually mounted to each client. While JDBC drivers are all written in Java, the JDBC code is
The Java platform (from the network computer to the host) can be automatically installed, and is portable and secure.
In short, jdbc api is a Java interface based on SQL abstraction and concepts. It is based on ODBC. Familiar with ODBC
It is easy for programmers to learn about JDBC. JDBC retains the basic design functions of ODBC. Both interfaces are based on X/opensq.
L CLI (call level interface ). The biggest difference is that JDBC maintains the Java style and advantages. Recently, m
Icrosoft introduces new APIs other than ODBC, including rdo, ADO, and ole db. Its design strategy is different from that of jdb in many aspects.
Similar to C, it is also an ODBC-based object-oriented database interface.

 

 

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.