Get the App
SLTechnology News&Howtos  ›  Database  › 

From shallow to deep learning JDBC II

Shulou Source: shulou.com Published: 2022-06-01 10:43:46 09月30日 Update

Encapsulate data access object

1: through the analysis and summary, all the operations on the database table can be summarized as the addition, deletion, modification and query of the table through JDBC, in order to reduce redundant code

So that it is not necessary to write JDBC programs every time you operate a table, so all data access functions to a table are encapsulated in the data access object.

(Data Access Object) for ease of calling.

2: in order to facilitate data transmission, the scattered field values of all related operations in java programs are often encapsulated into an entity object-entity.

Principles of entity encapsulation:

Table-entity class

Field-attribute

Implement serialization

Provides the set,get method.

The following code is written using the Dao data access object JDBC program, the use of encapsulation to simplify the JDBC development steps.

Just imagine, if there are 10 add requests, 20 delete requests, and write like the JDBC1.0,2.0 version, you have to write 10 times, 20 times a lot of similar code.

Basically consistent code. This is not only time-consuming and labor-consuming, but also does not conform to the three major characteristics of JAVA. Therefore, using the Dao data access layer, the common operations on the table

Encapsulated into a method, so that there are 10 more additions or 20 deletions, we only need to call the encapsulated add or delete method 10 times and 20 times.

Without having to write the method so many times, the development workload is greatly simplified.

The following is the use of Dao ideas to achieve JDBC3.0 is version 3.0, there is a better version to explain! > _ _ <

Tags: Methods codes versions files resources data queries encapsulation drivers objects results preparation processing configuration entities steps programs problems same no Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Technology Xiaomi Shulou Information NVidia