Now we can build and run our project to test this faculty record update function. Click on the Clean and Build Main Project button to clean up and build our project. Then click on the Run button to run our project. Enter the appropriate username and password, such as jhenry and test, to finish the login process, and select the Faculty Information item from the Selection.jsp page to open the Faculty.jsp page.
To update a faculty record, first let’s perform a query operation to retrieve and display that faculty record. Enter a faculty name, such as Ying Bai, into the Faculty Name field and click on the Select button. All seven pieces of information related to that faculty member are retrieved and displayed on this page. Now enter six pieces of updated information into the associ-ated six fields without the Faculty ID field, as shown in Figure 8.92, and click on the Browse button in the File Selector box to browse and select the updated faculty image, David.jpg, as our updated faculty image. The finished update record for the faculty member named David Bell is shown in Figure 8.92.
Click on the Update button to try to update this faculty record in the Faculty Table in our sample database. Immediately you can see that all TextFields become blank with the null value, which means that this data update is successful.
To confirm this data update action, two methods could be used. The first is to use the Select button on the Faculty.jsp page to retrieve the updated faculty record from the Faculty Table. To do that, enter David Bell in the Faculty Name field, and then click on the Select button. You can see that the updated record is retrieved and displayed in the seven fields with the updated faculty image, as shown in Figure 8.93.
Our data update action using the JavaServer Pages and Java bean is successful! Now just click on the Back and Exit buttons to terminate our project.
FIGURE 8.92 The updated faculty information.
FIGURE 8.93 The run result of confirming the data update action.
The second way to confirm this data updateis to open the Faculty Table. Perform the following operations to open the Faculty Table to check this update action:
1) In the NetBeans IDE 12.4, open the Services window by clicking on it at the top and expand the Databases node to find the URL folder, jdbc:oracle:thin:@ localhost:1521:XE.
2) Right-click on the URL, select the Connect item and enter the password, oracle _ 18c, to connect to our sample database.
3) Then expand our database, CSE _ DEPT, and Tables. Right-click on the Faculty Table and select the View Data item to open this Table.
You can see that the faculty record with the original faculty _ id of B78880 has been updated. It is highly recommended to recover the updated faculty record back to the original one. Run the project again and refer to Table 8.3 to perform another data update to do the recovery.
When doing this recovery or update action, the original faculty image file, Bai.jpg, can be found in the folder Images\Faculty in the Students folder on the CRC Press site (refer to Figure 1.2 in Chapter 1). One can copy and paste it into any local folder to use it.