Database Reference
In-Depth Information
Listing 12-37. Select Available Proxy from Table
String key = (String) availableProxiesTM.getValueAt (
availableProxiesTable. getSelectedRow(), 0 );
Vector dataVector = appsHashtable.get( key);
appsTM. setDataVector(dataVector , appColumnIdentifiers);
Having these pre-built lists of applications for each proxy saves us from having to make a call to
Oracle to get the list whenever the application user clicks on a different available proxy user. Getting
data from a local Hashtable is extremely fast, compared to opening an Oracle connection and querying
the database and handling the ResultSet . However, we only want to build data structures like this in
memory when we know the quantity of items to be stored is small.
Selecting a User from the List
Whenever a user is selected from the drop-down userComboBox , we will query Oracle to find what proxy
grants the user has already been given. This is done by the userComboBox_actionPerformed() method.
That method shows the sayWaitDialog message and executes a query in a delayed Thread , as we have
seen before. The run() method of that thread is shown in part in Listing 12-38.
Listing 12-38 should look familiar. We build a dataVector of one-item itemVectors that represents
our list of proxies granted to the selected user. In processing the ResultSet , we skip any returned rows
that are not for the selected user. After we have gathered the list of proxies, we set that as the data Vector
of the user proxies table model, userProxiesTM .
Listing 12-38. Selecting a User from the List
stmt = conn.createStatement();
rs = stmt.executeQuery(
"SELECT DISTINCT p.proxy, p.client FROM ojsaadm.instance_proxy_users p " +
"WHERE p.instance <> 'APVER' " +
"AND p.proxy NOT IN ('APPVER','AVADMIN','APPSEC','OJSAADM') " +
"ORDER BY p.proxy");
Vector dataVector = new Vector();
Vector itemVector;
while (rs.next()) {
if (rs.getString(2).equals(userID)) {
itemVector = new Vector();
itemVector.add(rs.getString(1));
dataVector.add(itemVector);
}
}
if (rs != null)
rs.close();
userProxiesTM.setDataVector(dataVector, columnIdentifiers) ;
Adding a Proxy to the User's List
When the Add Selected button is pressed, whatever proxy is selected in the available proxies list will be
added to the list of user proxies. This is accomplished by the code shown in Listing 12-39, which comes
from the addButton_actionPerformed() method.
 
Search WWH ::




Custom Search