Database Reference
In-Depth Information
}
});
// It may take a while to get the user data, esp while we set up encryption
// So ask the user to be patient while working
Login.sayWaitDialog.setVisible(true) ;
}
That method, existingEmpComboBox_actionPerformed() gets the employee ID from the selected item
by using the Utility.pullIdFromParens() method. Before we display the modal sayWaitDialog that will
dominate the current GUI Thread process until dismissed or made invisible, we create a new Runnable
Thread and pass it to the SwingUtilities.invokeLater() method. This delayed Thread will populate the
AddUser screen with data for the selected employee.
In our delayed thread run() method, we call two Oracle stored procedures, shown in abbreviated
form in Listings 12-20 and 12-22. The first procedure is one of our standard encrypted data queries from
Chapter 7, p_select_employee_by_id_sens . That procedure accomplishes key exchange, if not already
done, and selects data from the HR.EMPLOYEES table for the selected employee id. The salary and
commission_pct values are returned in encrypted form. We call OracleJavaSecure.getDecryptData() to
decrypt the values and then populate each field on AddUsers with the value we retrieved.
If there is an error with our call to p_select_employee_by_id_sens , we display an error message
dialog, which is a modal dialog. If there is no error, then we get the components of the shared password
(DES) key from the Oracle database. Our first call to OracleJavaSecure.getDecryptData() will have the
side effect of building an equivalent DES key for use in the client.
Listing 12-20. Abbreviated run() Method when Selecting Existing Employee, Part 1
public void run() {
int errNo;
String errMsg;
OracleCallableStatement stmt = null;
OracleResultSet rs = null;
try {
stmt =
(OracleCallableStatement)conn.prepareCall(
"CALL hr.hr_sec_pkg.p_select_employee_by_id_sens (?,?,?,?,?,?,?,?,?,?)");
...
stmt.setInt(10, employeeID );
stmt.executeUpdate();
errNo = stmt.getInt(8);
if (errNo != 0) {
errMsg = stmt.getString(9);
JOptionPane.showMessageDialog (thisComponent,
"Oracle error p_select_employee_by_id_sens) " + errNo + ", " + errMsg);
} else {
sessionSecretDESSalt = stmt.getRAW (3);
...
rs = (OracleResultSet)stmt.getCursor(7);
// Should be only one record for this Employee ID
if (rs.next()) {
firstNameTextField.setText (rs.getString(2));
...
// Our stored procedure passes Hire Date back as sql.Date
 
Search WWH ::




Custom Search