SET AS HOME PAGE

ADD TO FAVORITES / BOOKMARK THIS WEBSITE (More Details)

Introduction

Servlet

Jsp

Security

Enterprise Beans

Contact Us


Creating BMP Entity Beans - Project (Continue ...)

 Introduction

To solve the preceding problem, perform the following tasks:
  1. Configure a data source with the J2EE Application Server.
  2. Create the BMP entity bean home interface.
  3. Create the BMP entity bean remote interface.
  4. Create the BMP enity bean class.
  5. Create the Web Client.
  6. Package the BMP entity bean.
  7. Package the Web Client.
  8. Deploy the application.
  9. Test the application.

Types of Enterprise Beans are
  • Session Beans
    1. Stateless Session Beans
    2. Stateful Session Beans
  • Entity Beans
    1.  Bean Managed Persistent (BMP) Entity Beans
    2. Container Managed Persistent (CMP) Entity Beans
  • Message-Driven Bean
CLICK HERE to download this complete example (zip file)


 Steps to deploy and run this BMP Entity Bean - Project (Continue ...)

  1. Select the UserAccountBean in the left pane and select the Resource Refs tab in the right pane
  2. Now, click the Add button to add Resource Factories Referenced in Code. Here, enter jdbc/UserAccountDB in the Coded Name. Next select the jdbc/ejbUserAccount in the JNDI Name drop-down box and User Name as sa and Password as ***** (if password is given while installing the Microsoft SQL Server) (CLICK HERE for password)
  3. Next, goto File -> New -> Web Component

    (Click Next button)


  4. (Enter the WAR Name as “BmpApp” and then click the Edit Contents… button)


  5. (Select the UserAccountServlet.class and UserAccount.html files and click the Add button)


  6. (Now click the OK button)


  7. (Now click the Next button)


  8. (Now select the Servlet option button and then click the Next button)


  9. (Now select the UserAccountServlet from the Servlet Class dropdown box)


  10. (Now select the Next button)


  11. (Now select the Finish button)


  12. (Now select the BmpApp in the left pane and select the General tab in the right pane. Here give a name BMPAccountctx in the Context Root text box)
  13. Now select the ejb3 in the left pane and then select the Aliases tab in the right pane. Next, click the Add button and add the Aliases name as servlet/UserAccountServlet
  14. Now select the BmpApp in the left pane and then select the General tab

    ( Now press Alt+S or Sun-specific Settin… button )
  15. Now a Sun-specific Settings dialog box will open
  16. Now from the View drop-down box select JNDI Names and then in the Application pane enter the name as SimpleUserAccount in the JNDI Name tab
  17. Next, click the Close button
  18. Now goto File ->Save
  19. Next goto Tools -> Deployee

    (Enter the User Name as “admin” and Password as “password” (CLICK HERE for password). Next click the OK button)


  20. (Now a message --- Operation Completed Successfully --- must display. Next click the Close button)
  21. Next goto File -> Exit to close it
  22. Now open the SQL Query Analyzer and type the following query
    create database J2EE_DEMO
    use J2EE_DEMO
    create table useraccount(id varchar(20), name varchar(20), address varchar(20), phoneno varchar(20))
    Note: Here, while creating useraccount table first give the id varchar(20) because it is given as the findByPrimaryKey(String id){ … } in the Remote Interface
  23. Now open the Internet Explorer and type http://localhost:8080/BMPAccountctx/UserAccount.html in the address bar. Type the data in the required fields and click the SUBMIT button
  24. Now open the SQL Query Analyzer and type the following query, now you can see the data added in the database
    use J2EE_DEMO
    select * from useraccount
  25. Program completed successfully
  26. To stop the server goto Start -> All Programs -> Sun Microsystems -> Application Server PE -> Stop Default Server. CLICK HERE to see how to Stop the Server

 Click for Next Topic
<- PREVIOUSNEXT ->