Further improve the performance of JDBC applications (1)

zhaozj2021-02-08  244

Author: Zhao Yang pseudonym: bootcool

[bootcool @ 263.net, bootcool @ 163.net]

Beautiful and warm Kunming is actually very suitable for calm thinking

Further improve the performance of JDBC applications (1)

JDBC is a Java Database Connectivity API, and is also the core part of Java access to the database. Here, we don't prepare too much to repeat the history of JDBC and its various features. We tried to discuss JDBC from the performance issues of developers, and also introduce several basic policies and methods for improving JDBC performance. The author uses these methods in their own database access programs to enhance the performance of the program.

One: Select the appropriate JDBC driver mode and one of the considerations of programming.

So far, the JDBC driver has four modes. What model chooses primarily depends on the application range of the program. Correctly select the appropriate mode to make it in line with the design of the database program, which is an aspect that improves program performance must be considered. Here, we give a brief description of the four modes of the JDBC driver:

mode

Floor

Working Mechanism

Understand

1

2

JDBC-ODBC Bridge

Translate the JDBC operation into a corresponding ODBC call.

2

2

Native API / Group Java Drive

Translate JDBC operation into calls to a specific database.

3

3

Network protocol / full Java drive

Translate the JDBC operation into a network protocol and forward it to the intermediate server.

4

2

This level agreement / full Java drive

Convert JDBC operations into local protocols that do not use ODBC or native API.

(Table 1)

The following is an illustration of the four JDBC Driver mode:

The following is a simple evaluation of the four JDBC Driver modes:

mode

advantage

Disadvantage

1

Because most RDBMS platforms support ODBC drivers, use JDBC-ODBC bridges to work with a large number of ODBC drivers.

1: The user is subject to the functional limit of the underlying ODBC driver.

2: ODBC needs to be configured at each client.

3: Can't be used in the applet because the applet cannot load local calls.

2

It is not necessary to convert to ODBC calls, which is much better than mode 1.

Using Java local interface, platform transplantability is not good.

3

Widely applicable to the development, security and performance of Internet / Intranet is very significant.

When performing a database operation, it takes a long time.

4

Since the database is accessed through the native protocol, the performance is high.

Users need to use different JDBC drivers to different databases.

(Table 2)

Note 1: For small database developers currently not involved in large enterprises development deployment, mode 1 as a program is only a transitional solution, and we use charts to explain the drawbacks of mode 1:

(figure 2)

Recommendation: When mode 1 is used, since it needs to first translate the JDBC operation into a corresponding ODBC call, then these calls are passed to the ODBC driver, and finally, the database is executed, and it is clear that its performance is a big discount. Therefore, in the 2-layer structure, in order to improve the performance of the program, we best use the driver of mode 2.

Note 2: The database developers who carry out large enterprise development deployments are used as the design foundation, which is simply a nightmare. Select mode 3 in enterprise applications is wise. Because the author's experience is limited, the case 3 is not analyzed here.

Summary: The choice of different model drivers, the advantages and disadvantages, and the link between the procedural performance, we will not say much here. Although the mode 1 has a lot of bad, we still use the mode 1 as our experimental environment in the analysis.

Zhao Yang: 2002.3.31

Reference article:

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

New Post(0)