Srikanth Technologies

Integrating Struts With Hibernate Through DAO Pattern

I have developed a simple CRUD (Create Read Update and Delete) application using Struts as web framework, Hibernate for ORM and DAO (Data Access Object) design pattern.

Follow the steps given below to run this sample application using NetBeans 6.5.

  1. Download struts_hib_crud.rar.
  2. Use WinRar to extract it to C:\ drive so that c:\strut_hib_crud folder is created, which contains the project.
  3. When you open the project using NetBeans, it complains about missing references as libraries are removed from the .rar file to make download small.
  4. Go to properties of the project and remove references to libraries using Libraries node in project properties window. Select library and click on Remove button.
  5. Then add the following libraries to the project using libraries node. Use Add Library button or Add JAR/Folder button as the case may be.
    • Hibernate JPA
    • Struts 1.2.9
    • ojdbc14.jar for Oracle 10g
  6. Build project to make sure you have compiled all classes properly.
  7. Deploy the project. It starts Tomcat, if it is not already running.
  8. Before you run project, create the following table in Oracle database in HR account.
     create table subscribers
     ( 
      email varchar(50) primary key,
      fullname varchar(50),
      dj   date
     );
     

When you run the application, you get three options - List of Subscribers, Add New Subscriber and Delete Subscriber. List of subscribers displays the list of existing subscribers and allows you to modify the fullname of the subscriber using update form.