Java Reference
In-Depth Information
to:
if (actionBtn == e.getSource()) {
if (actionBtn.getLabel().equals("Insert")) {
emp.doInsert();
}
else { if (actionBtn.getLabel().equals("Update")) {
emp.doUpdate();
}
}
this .dispose();
Time to test.
12.
Run TNT, select Employee Application, Insert Employee Information, and then enter the
following employee information
333
Anne Analyst
3 Logic La
Jacksonville
FL 32233
22
1
13.
Click the Insert button.
14.
At the Employee Application Menu, select Display Employee and then, from the Select
Employee Number frame, select employee number 333.
The Anne Analyst information should be displayed in the Employee Information frame.
15.
Close the Employee Information frame and from the Employee Application Menu, select
Update Employee Information.
16.
Select employee number 333 from the Select Employee Number frame.
The Anne Analyst information will be shown on the Enter Employee Information frame.
17.
Change the street address to 4 Logic La and click the Update button.
18.
From the Employee Application Menu, select Display Employee Information and then,
from the Select Employee Number frame, select employee number 333.
The Employee Information frame will be displayed with the Anne Analyst information and the new value of 4
Logic La for the street address.
Yay, it works!! However, there are several shortcomings with our application. For instance, deleting an
employee's information is not an option on any of the frames, nor are there any checks to stop duplicate employee
information from being inserted into the database. This could have been easily solved by adding the delete option
to the Employee Options frame, coding the call to Employee's doDelete method, and doing a simple check before
inserting the new employee information. Also, navigating the frames to access the various functions is awkward.
Certainly, a Web page with links to all the functions (on the left side of the page) would be much easier. We also have
not been very careful about closing the connection—which wastes system resources. Finally, the way we create and
execute the SQL commands (dynamically) is very inefficient, especially for high-volume database applications. Using
PreparedStatement objects instead of Statement objects is more efficient. However, adding code to overcome these
shortcomings would have added to the complexity of the application and taken the focus away from the point of the
chapter, which was how to access a database.
 
Search WWH ::




Custom Search