Overview of Sample Java Application

This guide shows you how to create an application using Java, JDBC and Oracle ADF. In this application, you build in functions and features that:

  1. Allow users to log in and validate the user name and password.

  2. Establish a connection to the database.

  3. Query the database for data and retrieve the data using a JavaBean.

  4. Display the data using JavaServer Pages (JSP) technology.

  5. Allow users to insert, update, or delete records.

  6. Access and modify information from a master-detail application.

  7. Handle exceptions.

Note:

The application connects to the HR schema that ships with Oracle Database 12c Release 2 (12.2).

Overview of Application Web Pages (JSP Pages)

Figure 1-2 shows the relationships among the pages developed for this application.

A brief description of the Web pages in the sample application follows:

  • index.jsp

    This is the starting page of the application. It automatically forwards the user to the login page of the application, login.jsp.

  • login.jsp

    This page allows users to log in to the application. The user name, password, and host information are validated and used to create the connection descriptor to log in to the database.

  • login_action.jsp

    This is a nonviewable page that handles the authentication of the user-supplied login details from login.jsp. If authentication is successful, the page forwards the user to employees.jsp. Otherwise, it redisplays the login.jsp page including a message.

  • employees.jsp

    This is the main page of the application. It displays a list of all the employees in the HR schema for AnyCo Corporation and allows the user to filter the list of employees using any string. It also includes links to add, edit, and delete any user data. These actions, however, are handled by other JSP pages that are created specifically for each of these tasks.

  • insert.jsp

    The link to insert employee data on the employees.jsp page redirects the user to this page. This includes a form that accepts all the details for a new employee record. The details entered on this form are processed by the insert_action.jsp page.

  • insert_action.jsp

    This is a nonviewable page that handles the insertion of data for a new employee that is entered on the insert.jsp page.

  • edit.jsp

    The link to edit employee data on the employees.jsp page redirects the user to this page. This form displays current data of a single employee in text fields, and the user can edit this information.

  • update_action.jsp

    The submit action on the edit.jsp page directs the data to this nonviewable page, which inserts the edited data into the database.

  • delete_action.jsp

    The link to delete an employee record on the employees.jsp page is handled by this nonviewable page, which deletes the employee data and forwards the user back to the employees.jsp page.

Classes

The sample application includes the following classes:

  • DataHandler.java

    This class contains all the methods that are used to implement the important functions of the sample application. It includes methods that validate user credentials, connect to the database, retrieve employee data with and without filters, insert data, update data, handle exceptions, and so on.

  • Employees.java

    This class is a JavaBean that holds a single employee record. It contains access or methods to get and set the values of each of the record fields. It also contains accessor methods to retrieve and modify employee records.

  • JavaClient.java

    This class is used only for testing the DataHandler class.

Note:

This application is developed throughout this guide in the form of a tutorial. It is recommended, therefore, that you read these chapters in sequence.