9.15.6 Build Code for the Update Button Method to Update Course Records
The function of this method is to update an existing course record when the Update button is clicked by the user. The existing course record will be updated on the Course Table in our sample Oracle database when this method is complete.
As we discussed in previous sections, all columns for the selected course record will be updated except the course _ id column, since it is a primary key and a cascaded update setup has been selected when we built this database. A very complicated update operational sequence would be executed if that primary key were updated. A much easier way to do that update is to insert a new course record with a new course _ id.
To make thing simple, let’s modify our project WinClientCourse _ Insert to make it our new project, WinClientCourse _ UpdtDelt. Perform the following steps to build our new Windows-based project, WinClientCourse _ UpdtDelt:
1) Browse to our project WinClientCourse _ Insert, which can be found in the folder Class DB Projects\Chapter 9 in the Students folder on the CRC Press ftp site (refer to Figure 1.2 in Chapter 1), and copy and then save it to any local folder in your machine.
2) Open NetBeans IDE 12.0 and right-click WinClientCourse _ Insert from your local folder and select the Copy item from the popup menu.
3) On the opened Copy Project wizard, change the project name to WinClientCourse _ UpdtDelt in the Project Name box, select your desired location from the Project Location box, and click on the Copy button.

FIGURE 9.95 The completed code for the UpdateButtonActionPerformed() event handler.
The main source file, CourseFrame.java, in our Source Packages folder may generate some errors when this new project is created. The reason for that is due to a Web Reference issue. To fix this error, build and deploy our Web Service application project, WebAppCourse, and then rebuild our new project, WinClientCourse _ UpdtDelt.
Now let’s first build the code for the Update button’s event handler. In the opened Design view of the CourseFrame form window, double-click on the Update button to open its event handler. Enter the code shown in Figure 9.95 into this event handler. Let’s have a closer look at this piece of code to see how it works.