Next let’s build the code for our Java bean class file, CourseQuery.java. Double-click on this file in the Projects window, under Source Packages\JavaWebOracleSelect-Package, to open it and enter the code shown in Figure 9.115 into the bottom of this file. Let’s have a closer look at this piece of code to see how it works.
A. A local boolean variable, delete, is generated first and it is used to hold the run result of execution of our Web Service operation, DeleteCourse(), later.
B. A try-catch block is used to call our Web operation, DeleteCourse(), to delete a selected course record from our sample database via our Web service. First a new Web service instance, service, is created based on our Web service class,WebServiceCourse _ Service. Then the getWebServiceCoursePort() method is executed to get the current port used by our Web service. This port is returned and assigned to a new port instance, port.
C. The Web Service operation DeleteCourse() is executed with a String argument, dCourse, that is a valid course _ id, which is related to a course record to be deleted from our database.
D. If a false is returned, which means that this data delete action fails, a system method, println(), is used to indicate this. Otherwise, the data delete is successful.
E. The catch block is used to monitor and check any possible exception during the data delete process. A false is returned to the calling program if an error really occurs.
F. Otherwise, a true is returned to indicate the success of the data delete action.
Now we have finished all code for this course delete action. Let’s build and run our client proj-ect to consume our Web Service to delete a selected course record from the Course Table in our sample database.

FIGURE 9.115 The code for the Delete_Course() method in the Java bean.
Prior to building and running our client project, make sure that our Web Service project, WebAppCourse, has been built and deployed successfully.
Perform the following operations to build and run our client project, WebClientCourse _ Delete:
- Click on the Clean and Build Main Project button to build our project.
- Then click on the Run Project button (green arrow) on the top to run our project.
As the project is running, enter a valid faculty name, such as Ying Bai, into the Faculty Name box, and then click on the Select button to query all courses (course _ id) taught by this fac-ulty member. All courses (course _ id) are retrieved and displayed in the CourseList box.
Now let’s test deleting an existing course record, CSE-565, from the Course Table in our sam-ple database. Keep the selected faculty member, Ying Bai, with no change, and click on the course CSE-565 from the CourseList box to select it. Click on the Details button to get more details about this course, as shown in Figure 9.116. Then click on the Delete button to try to remove this course record from the Course Table in our sample database.
To confirm or test the data delete action, keep the selected faculty member Ying Bai with no change, and click on the Select button again to try to retrieve all courses (course _ id) taught by this faculty member. Immediately one can see that four courses (course _ id) are returned and displayed in the CourseList box without course CSE-565. This confirms that course CSE-565 has been deleted successfully from the Course Table in our sample database.
Another way to confirm the course delete action is to open the Course Table in our sample database, CSE _ DEPT, by using the Services window in the NetBeans IDE 12.0 environment. The course CSE-565 cannot be found in our Course Table, which means that it has been deleted from the Course Table.
It is highly recommended to recover any deleted records to keep our database clean. An easy way to do this recovery is to perform another insert action via the Insert button on our client page to insert this course record in the Course Table. Refer to course details displayed in the six TextFields shown in Figure 9.116 to do this recovery.
Click on the Back and the Exit buttons to terminate our Web client project.