BUILD A JAVA WEB PROJECT TO MANIPULATE DATA IN THE ORACLE DATABASE – Develop Java Web Applications to Access Databases

8.5  BUILD A JAVA WEB PROJECT TO MANIPULATE DATA IN THE ORACLE DATABASE

Now let’s take care of manipulating data against our Oracle 18c XE database by using different methodologies, which include inserting, updating and deleting records from our sample database, CSE _ DEPT, via our Web application project.

FIGURE 8.78   The opened Copy Project wizard.

First let’s take care of inserting a new record into our Faculty Table in our sample database, CSE _ DEPT. To do that, we need to create a new Web project, JavaWebOracleInsert. In order to save time and space, we can copy and modify the project JavaWebOracleSelect that we built in the last section and make it our new project.

Perform the following steps to create this new project:

1) In the Projects window, right-click on the project JavaWebOracleSelect and select the Copy item from the popup menu to open the Copy Project wizard, as shown in Figure 8.78.
2) Enter our new project name, JavaWebOracleInsert, into the Project Name box, and browse to the default project folder, C:\Class DB Projects\Chapter 8, as the Project Location, which is shown in Figure 8.78, and click on the Copy button.

A new project, JavaWebOracleInsert, is generated and added into our Projects window. Next let’s build the code for the related pages to insert some new records into the Faculty Table in our sample database.

8.5.1  Modify the Faculty.jsp Page by Adding a File Selection Function

In order to insert a new faculty record, especially to insert a new faculty image, into our sample database, a File Selection function should be added to the Faculty.jsp page to provide a way to enable users to select a desired faculty image for the new inserted faculty member. Perform the following steps to add this function:

1) On the opened Faculty.jsp page, scroll down to find one of the input tags, which should be around line 381:
2) Enter the following tag located just above the previous tag:

FIGURE 8.79   The modified code for the Faculty.jsp page.

FIGURE 8.80   The run result of modified Faculty.jsp page.

Your modified Faculty.jsp page should match the one shown in Figure 8.79. The new added tag part is in bold.

Now go to the Projects window and right-click on our modified Faculty.jsp file, and click on the Clean and Build Main Project button to build our project. Then click on the Run button to run our project. Complete the login process and select the Faculty Information item from the Selection.jsp page to open the Faculty.jsp page. The run result of that page is shown in Figure 8.80. One File Selection tag is added at the top of the Faculty Image TextField, which can be used to select a faculty image to be inserted.

Next we can begin our code development for this data insertion action.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *