## Reviewing the Employee Information System

When the Employee intranet portal is loaded, the UsersDBControl database control connects to the employee information database to retrieve the employee profile for the current user.

A database control is one example of a built-in Java control. This type of control makes it easy to access a relational database from your application. You simply issue SQL commands to the database and the database control performs the following tasks on your behalf:

- Connects to the database—you do not have to understand Java Database Connectivity (JDBC).
- Automatically performs the translation from database queries to Java objects simplifying access to the results.

When you add a new database control to your application, you specify the following:

1. Variable name for the control.
2. Whether you want to add a new database control file or reference an existing one.
3. Data source to which the control is bound (if you are creating a new control file in step 2).

View the UsersDbControl database control in WebLogic Workshop by performing the following steps:

1. In the Application window, expand the e2ePortal/JoinDB/joindb folder, as shown:

2. Open the database control by double-clicking UsersDBControl.jcx.

The UsersDBControl database control and the methods associated with it are displayed, as follows:

The database control provides a number of methods for accessing the employee information database.

3. Open the Employee page flow file by double-clicking e2ePortalProject/employee/Controller.jpf.
4. Select the Action View tab.

An instance of the UsersDBControl database control, m_DBCtrl, and the methods associated with it are displayed on the right-hand side of the page flow.

5. Select the Source View tab.

The m_DBCtrl instance is used to look up the current user and populate the InfoForm form bean with the employee profile information.

    HttpSession sess= getSession();
    HttpServletRequest req=getRequest();
    joindb.UsersDBControl.User user= null;
    .
    .
    .
    user = m_DBCtrl.lookupUser(empId);
    .
    .
    .
    if(user==null)
      return new Forward( "theFirstPage" );
    else {
      sess.setAttribute("employeeid",user.employeeid);
      sess.setAttribute("employeename",user.employeename);
      sess.setAttribute("ssn",user.ssn);
      sess.setAttribute("departmentid",user.deptid);
      sess.setAttribute("mgrname",user.mgrname);
      sess.setAttribute("dateofhire",user.dohire);
      sess.setAttribute("salary",user.sal);
      sess.setAttribute("officeaddress",user.address);
      sess.setAttribute("homephone",user.homephone);
      sess.setAttribute("businessphone",user.bussphone);
      sess.setAttribute("position",user.position);
      sess.setAttribute("email",user.email);
    }
    return new Forward( "theFirstPage" );
    }
    .
    .
    .
    protected Forward UsrInfo(InfoForm form)
    {
    	return new Forward("success");
    }

Before proceeding to the next step in the WebLogic Platform Tour:

1. Close all open files by choosing File —> Close Files
2. To conserve screen real estate, temporarily minimize the WebLogic Workshop window.