The DAO design pattern can be used to provide a separation between the low-level data accessing operations and the high-level business services, as shown here:
In between the database and the business layer, there is a layer called the DAO layer. The DAO layer is mainly used to perform the Create-Retrieve-Update-Delete (CRUD) operation. The DAO layer is responsible for creating, obtaining, updating, or deleting records in the database table. To perform this CRUD operation, DAO uses a low-level API, such as the JDBC API or the Hibernate API. This DAO layer will have a method for performing the CRUD operation. It is the intermediate layer between the Business Layer and the DB. It is used to separate the low-level accessing API from the high-level business service. The DAO layer decouples the implementation of persistent storage from the rest of your application.
The advantages of using DAO are as follows: