JDBC introduction (1)

xiaoxiao2021-03-06  16

JDBC is used for execution

SQL

of

Java API

, It takes data inventory

API

versus

SQL

The statement is separated, realizing the database-independent

API

Interface, by

JDBC

Unified interface, developers only

SQL

Statement, but you can ignite the underlying database driver and related interface.

Using JDBC, by the vendor's interface, the SQL's operation part is responsible by the Java program designer. If you want to replace the driver, you can load the new driver source, and the part of the Java program does not need to be changed.

Simply put, JDBC allows the Java programming staff to write a program and apply all databases when writing database programs.

The relationship between the JDBC API, the database driver and the database:

:

The JDBC database driver can be divided into four types according to the board:

TYPE 1: JDBC-ODBC Bridge

The ODBC driver must be installed in advance on the user's computer, and the Type 1 driver uses Bridge to convert JDBC's call mode to ODBC's call mode for Microsoft Access, which is:

Application <-> JDBC-ODBC Bridge <-> ODBC Driver <-> Database

TYPE 2: Native-API Bridge

The upper layer packaged Java program is communicated with the Java application, convert the JDBC call to the original program code, the lower layer is the native language (like C, C ) to communicate with the database, the lower layer of the library is for specific Database design, not if Type 1 can access the database of the ODBC architecture:

Application <-> Native-API Bridge <-> Native Driver <-> Database

TYPE 3: JDBC-MIDDLEWARE

Access the database through the middleware, the user does not have to install a specific driver, but by the driver call middleware, all data inventory is done, and then transmit the result back to the driver:

Application <-> JDBC-MIDDLEWARE <-> MiddleWare <-> Database

TYPE 4: Pure Java Driver

Use pure Java write drivers to communicate with the database, not to access the database through bridging or middleware:

Application <-> Pure Java Driver <-> Database

MySQL's JDBC driver belongs to Type 4, called Connector / J, currently supports version of JDBC 2.0 and JDBC 3.0, you can get in the following website:

http://www.mysql.com/products/connector-j/index.html

转载请注明原文地址:https://www.9cbs.com/read-58560.html

New Post(0)