⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 savingsaccountclient.java

📁 本教程介绍j2ee企业开发方面的知识
💻 JAVA
字号:
/* * * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. *  * This software is the proprietary information of Sun Microsystems, Inc.   * Use is subject to license terms. *  */import java.util.*;import javax.naming.Context;import javax.naming.InitialContext;import javax.rmi.PortableRemoteObject;public class SavingsAccountClient {   public static void main(String[] args) {       try {           Context initial = new InitialContext();           Object objref = initial.lookup("java:comp/env/ejb/SimpleSavingsAccount");           SavingsAccountHome home =                (SavingsAccountHome)PortableRemoteObject.narrow(objref,                                             SavingsAccountHome.class);           SavingsAccount duke = home.create("123", "Duke", "Earl", 0.00);           duke.credit(88.50);           duke.debit(20.25);           double balance = duke.getBalance();           System.out.println("balance = " + String.valueOf(balance));           duke.remove();           SavingsAccount joe = home.create("836", "Joe", "Jones", 0.00);           joe.credit(34.55);           SavingsAccount jones = home.findByPrimaryKey("836");           jones.debit(2.00);           balance = jones.getBalance();           System.out.println("balance = " + String.valueOf(balance));           SavingsAccount pat = home.create("456", "Pat", "Smith", 0.00);           pat.credit(44.77);           SavingsAccount john = home.create("730", "John", "Smith", 0.00);           john.credit(19.54);           SavingsAccount mary = home.create("268", "Mary", "Smith", 0.00);           mary.credit(100.07);           Collection c = home.findByLastName("Smith");           Iterator i=c.iterator();           while (i.hasNext()) {              SavingsAccount account = (SavingsAccount)i.next();              String id = (String)account.getPrimaryKey();              double amount = account.getBalance();               System.out.println(id + ": " + String.valueOf(amount));           }           c = home.findInRange(20.00, 99.00);           i=c.iterator();           while (i.hasNext()) {              SavingsAccount account = (SavingsAccount)i.next();              String id = (String)account.getPrimaryKey();              double amount = account.getBalance();               System.out.println(id + ": " + String.valueOf(amount));           }           System.exit(0);       } catch (InsufficientBalanceException ex) {           System.err.println("Caught an InsufficientBalanceException: "                                + ex.getMessage());       } catch (Exception ex) {           System.err.println("Caught an exception." );           ex.printStackTrace();       }   } } 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -