FileDocCategorySizeDatePackage
Client_2.javaAPI DocExample1430Sun Dec 12 13:29:56 GMT 1999com.titan.ship

Client_2

public class Client_2 extends Object

Fields Summary
Constructors Summary
Methods Summary
public static javax.naming.ContextgetInitialContext()

        Properties p = new Properties();
        // ... Specify the JNDI properties specific to the vendor.
        return new javax.naming.InitialContext(p);
    
public static voidmain(java.lang.String[] args)

        try {
            Context ctx = getInitialContext();
            // EJB 1.1: Use PortableRemoteObject.narrow() method
            ShipHome home = (ShipHome)ctx.lookup("ShipHome");
            home.create(2,"Utopia",4500,8939);
            home.create(3,"Valhalla",3300,93939);
            ShipPK pk = new ShipPK();
            pk.id = 1;
            Ship ship = home.findByPrimaryKey(pk);
            ship.setCapacity(4500);
            int capacity = ship.getCapacity();
            
            Enumeration enum = home.findByCapacity(4500);
            while (enum.hasMoreElements()){
                // EJB 1.1: Use PortableRemoteObject.narrow() method
                Ship aShip = (Ship)enum.nextElement();
                System.out.println(aShip.getName());
            }
        } catch (Exception e){e.printStackTrace();}