Java Reference
In-Depth Information
When a user selects the display or update options on EmpOptions, a new frame, EmpNumFrame, will be
displayed. EmpNum-Frame's choice box will contain all the employee numbers from TNTDB, so that the user can
click on which employee's information (i.e., employee number) to update or display (see Figure 10-12 ). We will
modify the Employee and EnterEmpInfo classes to support these new features.
Figure 10-12.
Tutorial: Using a Database in an Application
Now it's time to use the database:
1.
Copy the following classes from Tutorials/c7 to Tutorials/c10:
AppOptions EmployeeFrame EnterEmpInfo
ExitButton TNT TNTButton
UsefulFrame
There will be several errors displayed because c10 doesn't have an Employee class.
2.
Copy the Employee class from TutorialsWeb/src/c9java to Tutorials/c10
3.
In DBAccess's constructor, comment out the println statements that display the following:
Driver class found!
Connection created!
Statement created!
4.
In DBAccess's constructor, comment out the statements that were added in steps 9 and 11
of the last tutorial.
5.
In DBAccess, comment out the close connection statement and the main method.
The executable code should look like the following (with your information substituted in the driver, url, userid
and pw strings):
package c10;
import java.sql.*;
public class DBAccess {
private String driver = new String("xxx.xxx.xDriver");
private String url = new String("jdbc:xxx:111.22.333.444");
 
Search WWH ::




Custom Search