What is the use of DAO( Data Access Object)
12/3/10
DAO pattern is uesd for connecting with the backend softwares like DBMS and FILE SYSTEMS.
The follwoing are the Sample code for creating DAO.
<pre class="java" name="code">
public interface EmpDAO
{
void createEmp();
Employee getEmpByID(int id);
List getEmpsByDepartment(int did);
}
</pre>
We need to implement the above interface(EmpDAO).
The follwoing is the implementation class for Oracle Data Base.
<pre class="java" name="code">
public class ImpOracleEmp implemnets EmpDAO
{
/* write the code for implementing methods that are specific to Oracle Data Base */
}
</pre>
The follwoing is the implementation class for XML.
<pre class="java" name="code">
public class ImpXMLEmp implemnets EmpDAO
{
/* write the code for implementing methods that are specific to XML*/
}
</pre>