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

📄 customerdaobean.java~57~

📁 郭克华j2ee高级框架实战教学视频源代码 这个是比较值得一看的 由郭克华博士在总结多年Java培训的基础上
💻 JAVA~57~
字号:
package prj37_1;

import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import javax.rmi.PortableRemoteObject;
import factory.EjbFactory;

public class CustomerDaoBean
    implements SessionBean {
  SessionContext sessionContext;

  TCustomerRemoteHome home;
  TCustomerRemote remote;

  public void setSessionContext(SessionContext sessionContext) {
    Object obj = EjbFactory.getEjbHome("TCustomerRemote");
    home = (TCustomerRemoteHome)PortableRemoteObject.narrow(obj,TCustomerRemoteHome.class);
    this.sessionContext = sessionContext;
}

  public void ejbCreate() throws CreateException {
  }

  public void ejbRemove() {
  }

  public void ejbActivate() {
  }

  public void ejbPassivate() {
  }



  public boolean insert(CustomerDto cus) {
    try {
      String account = cus.getAccount();
      String password = cus.getPassword();
      String cname = cus.getCname();
      double cbalance = cus.getCbalance();
      remote = home.create(account);
      remote.setPassword(password);
      remote.setCname(cname);
      remote.setCbalance(new Float(cbalance));
      return true;
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
    return false;
  }

  public boolean update(CustomerDto cus) {
    try {
      String account = cus.getAccount();
      String password = cus.getPassword();
      String cname = cus.getCname();
      double cbalance = cus.getCbalance();
      remote = home.findByPrimaryKey(account);
      remote.setPassword(password);
      remote.setCname(cname);
      remote.setCbalance(new Float(cbalance));
      return true;
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
    return false;

  }

  public boolean delete(CustomerDto cus) {
    try {
      String account = cus.getAccount();
      remote = home.findByPrimaryKey(account);
      remote.remove();
      return true;
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
    return false;
  }

  public CustomerDto findCusByAccount(String account) {
    CustomerDto cus = null;
    try {
     remote = home.findByPrimaryKey(account);
     Object obj = EjbFactory.getEjbHome("CustomerDto");
     CustomerDtoHome cusHome = (CustomerDtoHome)PortableRemoteObject.narrow(obj,)
   }
   catch (Exception ex) {
     ex.printStackTrace();
   }
   return cus;

  }
}

⌨️ 快捷键说明

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