Java DAO Design Pattern

Source: Internet
Author: User

I. Development structure of information systems

Client layer-------Display layer-------Business layer---------data layer---------Database

1. Customer Layer: The client layer is the clients, the simple is the browser.

2. Display layer: Jsp/servlet for display to the browser.

3. Business layer: Consolidates the atomic operations of the data layer .

4. Data layer: Atomic operations for databases, additions, deletions, etc.;

Second, DAO (Data Access Object) Introduction

DAO is applied to the data layer, which is used to access the database and manipulate the database class.

Third, the structure of DAO design pattern

DAO design patterns generally fall into several categories:

1.VO (Value Object): A class that holds a row of data for a Web page that is a record, such as a Web page to display a user's information, the class is the user's class.

2.DatabaseConnection: Used to open and close the database.

3.DAO interface: Used to declare operations for a database.

4.DAOImpl: DAO interface must be implemented, real implementation of the DAO interface functions, but does not include the opening and closing of the database.

5.DAOProxy: The DAO interface is implemented, but only with Daoimpl, but includes the opening and closing of the database.

6.DAOFactory: Factory class, containing getinstance () create a proxy class.

Iv. Benefits of DAO

The advantage of DAO is that the interface provided to the user is only a DAO interface, so if the user wants to add data, only the CREATE function needs to be called, and the operation of the database is not required.

Five, DAO package naming

For DAO, the naming of packages and the naming of classes must be hierarchical.

The core idea of DAO Pattern:

1. All database accesses are done through the DAO component, and the DAO component encapsulates the atomic operations such as CRUD.

2, the business logic component relies on the database atomic operation provided by DAO component, and accomplishes the system business logic.

Java DAO Design Pattern

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.