Database Reference
In-Depth Information
// So process here to format
java.sql.Date sDate = rs.getDate(6);
Date hDate = new Date(sDate.getTime());
hireDateTextField.setText(hDateFormat.format(hDate)) ;
jobIDComboBox.setSelectedItem (rs.getString(7));
deptIDComboBox.setSelectedItem(rs.getString(11));
// Find this user's manager id in parentheses of combo box
for (int i = 0; i < managerIDComboBox.getItemCount(); i++) {
if (rs.getString(10).equals(Utility.pullIDFromParens(
(String)managerIDComboBox.getItemAt(i))))
{
managerIDComboBox.setSelectedIndex (i);
break;
}
}
// Decrypt salary and commission pct using shared password key
salaryTextField.setText(OracleJavaSecure.getDecryptData (rs.getRAW(8),
sessionSecretDESPassPhrase, sessionSecretDESAlgorithm,
sessionSecretDESSalt, sessionSecretDESIterationCount));
commissionPctTextField.setText(
OracleJavaSecure.getDecryptData (rs.getRAW(9),
sessionSecretDESPassPhrase, sessionSecretDESAlgorithm,
sessionSecretDESSalt, sessionSecretDESIterationCount));
}
if (rs != null) rs.close();
if (stmt != null) stmt.close();
}
You can see in Listing 12-20 how we populate the AddUser form with certain data elements. We
simply set the text of text fields on the form. For the date field, we take pains to convert the
java.sql.Date into a java.util.Date , and we format the date using our static hDateFormat member,
which was defined like this:
static SimpleDateFormat hDateFormat = new SimpleDateFormat("MM/dd/yy");
For our drop-down combo boxes, e.g., jobIDComboBox , we select the item in the existing list that
corresponds with the value from our query. In the particular case of the managerIDComboBox , we walk
through all the items in the existing list and call the pullIDFromParens() method to get the manager's
employee ID. If that matches the manager ID we got from our query, we set that manager as our selected
item. Also, you can see, we set the value for the salaryTextField and commissionPctTextField to the
value we get from decrypting the data we received from our query.
We also populate the user data on the bottom half of the AddUser screen with data from the user
mobile numbers view, hr.v_emp_mobile_nos . To do that, we call a new procedure in a package that we
are defining in the HR schema, hr_pub_pkg.p_select_emp_mobile_nos_by_id . The script for creating this
package is shown in Listing 12-21. This script should look very familiar to you at this point. Notice there
are two procedures defined, the select procedure we already mentioned, and a procedure that we will
use to update the data in v_emp_mobile_nos , named p_update_emp_mobile_nos . We grant execute on this
package to hrview_role .
 
Search WWH ::




Custom Search