Wednesday, September 28, 2011

How to Create DAO using Java

What is DAO (Data Access Object) ? Maybe it's that currently exists in your mind. It’s very reasonable because it’s usually spoken by someone who is just learning programming. About what DAO is will be discussed by the Ar-Rohman Software House Team in another post, so please be patient to wait. In this post we will explain how to make it directly(we got this idea after completing the DAO of Equipment History Software).

The following steps create a DAO using Java :
1. Creating a Database and it Tables
Creating a database first and it tables that accordance with the requirements before creating and using DAO.

2. Creating a Class for each Table (DAO)
Creating a class according to the number of tables that have been made in step 1. Class contains a variable (accordance with the existing fields in the table) that has been encapsulated.

3. Creating DAO Interface
Creating an interface that contains the method then applied to each table. For example if the relevant table will be conducted a DML (Data Manipulation Language) then insert, update, and delete method will be created. This interface importing related and needed classes.

4. Creating a Class to implement DAO Interface
Creating a class that implements the interface in step 3. This class contains the database connection, query, override the interface method, and filling all the methods that accordance with the declared methods in the interface. This class importing related and needed classes.

5. Creating a Factory Class to make DAO Object
Creating a class that called Factory to create a DAO objects from a class that implements the DAO Interface. This class importing related and needed classes.

6. Using DAO
Instantiating the classes in step 2 then call the method and send the parameters through TestUnit Class. This class importing related and needed classes.

Because the steps are quite complicated, so each step we will explain again in another post. For those who already know please directly try it. We hope this post will be helpful. Thanks ...

1 comments:

Das dis dusssss....... gak dong om.... hehehehehe.....
pake mbah google translate mbacanya....

Post a Comment

If you have something to say about this post, please fell free to write it in the comment form below. We will reply to all comments as soon as possible. Thanks ...