From shallow to deep learning JDBC II
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! > _ _ <