1 31 32 36 37 38 package enterprise.customer_cmp_appclient; 39 40 import javax.naming.InitialContext ; 41 import java.util.List ; 42 import javax.ejb.EJB ; 43 import enterprise.customer_cmp_ejb.ejb.session.CustomerSessionRemote; 44 import enterprise.customer_cmp_ejb.persistence.*; 45 46 public class CustomerAppClient { 47 48 @EJB 49 private static CustomerSessionRemote sess; 50 51 public static void main(String args[]) { 52 try { 53 InitialContext ic = new InitialContext (); 54 String CUSTOMER_ID="99999"; 55 56 System.out.println("Searching for customer with id:"+CUSTOMER_ID); 57 Customer searchedCustomer= sess.searchForCustomer(CUSTOMER_ID); 58 59 if(searchedCustomer==null){ 60 throw new Exception ("searched customer not found"); 61 } 62 63 System.out.println("found customer with id:"+CUSTOMER_ID); 64 System.out.println("First Name:"+searchedCustomer.getFirstName()); 65 System.out.println("Last Name:"+searchedCustomer.getLastName()); 66 67 } catch(Exception e) { 68 e.printStackTrace(); 69 } 70 } 71 72 } | Popular Tags |