KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tutorial > secondary > client > Client


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.tutorial.secondary.client;
8
9 import org.jboss.tutorial.secondary.bean.Customer;
10 import org.jboss.tutorial.secondary.bean.CustomerDAO;
11
12 import javax.naming.InitialContext JavaDoc;
13
14 import java.util.List JavaDoc;
15
16
17 public class Client
18 {
19    public static void main(String JavaDoc[] args) throws Exception JavaDoc
20    {
21
22       InitialContext JavaDoc ctx = new InitialContext JavaDoc();
23       CustomerDAO dao = (CustomerDAO) ctx.lookup(CustomerDAO.class.getName());
24
25       System.out.println("Create Bill Burke and Monica Smith");
26       dao.create("Bill", "Burke", "1 Boston Road", "Boston", "MA", "02115");
27       int moId = dao.create("Monica", "Smith", "1 Boston Road", "Boston", "MA", "02115");
28
29       System.out.println("Bill and Monica get married");
30       Customer monica = dao.find(moId);
31       monica.setLast("Burke");
32       dao.merge(monica);
33
34       System.out.println("Get all the Burkes");
35       List JavaDoc burkes = dao.findByLastName("Burke");
36       System.out.println("There are now " + burkes.size() + " Burkes");
37    }
38 }
39
Popular Tags