DAO In Java

DAO In Java

DAO in Java, section describes you the pattern for specifying the accessibility of data from the database.

DAO in Java, section describes you the pattern for specifying the accessibility of data from the database.

DAO In Java

In this section we will read about the DAO in Java.

DAO is a pattern that separates the high level business logic from the data
accessing operations. DAO allows you to write the code for working with the
database's data. DAO makes your code complexity less compare to the code writing
together business logic and data accessing operations. A Data Access Object
pattern may have the following participants :

An Interface : A DAO interface may declare the important
operations required to perform on Model Objects.

A Class : A DAO can be a concrete class that may implement
the DAO interface or may define the operations required to perform on Model
Objects. This class has the main role that plays for getting the data from
datasource i.e. database, XML or any other storage mechanism.

Model Object : Model Object may be called a POJO class that
has the data members and their setter/getter methods to store the data retrieved
through the DAO Class.

How To Create A DAO In Java?

To create a DAO in Java we may include all/part of its participant discussed
above. From the given participant we may or not create an interface we can
directly define the operations in the concrete class that has to be perform.
But, in my example I will include all of its participant i.e. I will create an
interface, class and model object.