Skip to content

Build Code for the Insert Button Event Handler to Insert a New Course – ORACLE DATABASE PROGRAMMING WITH JAVA

Menu
  • Contact Us
Menu

Build Our Client Project to Delete Course Records via Our Web Service 2 – Develop Java Web Services to Access Databases

Posted on 2022-05-202024-08-24 by Patricia Carey

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:

  1. Click on the Clean and Build Main Project button to build our project.
  2. 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.

Leave a Reply Cancel reply

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

  • August 2024
  • April 2024
  • March 2024
  • January 2024
  • September 2023
  • May 2023
  • January 2023
  • October 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • January 2022
  • November 2021
  • September 2021
  • July 2021
  • May 2021
  • March 2021
  • January 2021
July 2025
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  
« Aug    
  • Creating the Catalog Database
  • Creating the Shard Catalog
  • Exams of Oracle
  • GDS Components
  • GDS Restrictions, License, and Compatibility
  • Oracle Certification Exams
  • Oracle Sharding Workshop
  • Build Code for the Insert Button Event Handler to Insert a New Course 2 – Develop Java Web Services to Access Databases
  • Build Code for the Insert Button Event Handler to Insert a New Course – Develop Java Web Services to Access Databases
  • Build Code for the Update Button Method to Update Course Records – Develop Java Web Services to Access Databases
  • Build Code for the Update Button Method to Update Course Records 2 – Develop Java Web Services to Access Databases
  • Build Code for the Delete Button Method to Delete Course Records – Develop Java Web Services to Access Databases
© 2025 Build Code for the Insert Button Event Handler to Insert a New Course – ORACLE DATABASE PROGRAMMING WITH JAVA | Powered by Minimalist Blog