what is dao in java

what is dao in java

1 year ago 73
Nature

DAO stands for Data Access Object, which is a design pattern used to separate low-level data accessing API or operations from high-level business services in Java. The DAO pattern allows the service to remain completely unaware of how the low-level operations to access the database are done, which is known as the principle of Separation of Logic. With the DAO design pattern, we have the following components on which our design depends:

  • Data Access Object Interface: This interface defines the standard operations to be performed on a model object(s).
  • Data Access Object Concrete Class: This class implements the above interface. This class is responsible for getting data from a data source, which can be a database, XML, or any other storage mechanism.
  • Model Object or Value Object: This object is a simple POJO containing get/set methods to store data retrieved using the DAO class.

The DAO pattern is used to manage the connection with the data source to obtain and store data. The DAO implements the access mechanism required to work with the data source, which could be a persistent store like an RDBMS, an external service like a B2B exchange, a repository like an LDAP database, or a business service accessed via CORBA Internet Inter-ORB Protocol (IIOP) or low-level sockets. The DAO completely hides the data source implementation details from its clients, allowing the DAO to adapt to different storage schemes without affecting its clients or business components.

Read Entire Article