try
{
if (args.length<3 || args.length%3!=0)
{
System.out.println("Usage: java com.titan.clients.Client_61 <pk1> <fname1> <lname1> ...");
System.exit(-1);
}
// obtain CustomerHome
Context jndiContext = getInitialContext();
Object obj = jndiContext.lookup("CustomerHomeRemote");
CustomerHomeRemote home = (CustomerHomeRemote)
PortableRemoteObject.narrow(obj, CustomerHomeRemote.class);
// create Customers
for(int i = 0; i < args.length; i++)
{
Integer primaryKey = new Integer(args[i]);
String firstName = args[++i];
String lastName = args[++i];
CustomerRemote customer = home.create(primaryKey);
customer.setFirstName(firstName);
customer.setLastName(lastName);
customer.setHasGoodCredit(true);
}
// find and remove Customers
for(int i = 0; i < args.length; i+=3)
{
Integer primaryKey = new Integer(args[i]);
CustomerRemote customer = home.findByPrimaryKey(primaryKey);
String lastName = customer.getLastName( );
String firstName = customer.getFirstName( );
System.out.print(primaryKey+" = ");
System.out.println(firstName+" "+lastName);
// remove Customer
customer.remove();
}
}
catch (java.rmi.RemoteException re)
{
re.printStackTrace();
}
catch (Throwable t)
{
t.printStackTrace();
}