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

📄 facadebean.java

📁 书籍源程序《J2EE应用开发(WebLogic+JBuilder)》代码
💻 JAVA
字号:
package cmpsample;

import javax.naming.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;

import javax.ejb.*;

public class facadeBean implements SessionBean {
  SessionContext sessionContext;
  public Student student=null;
  public StudentHome studentHome=null;
  public void ejbCreate() throws CreateException {
    /**@todo Complete this method*/
    try{
    Context context = new InitialContext();

      //look up jndi name
      Object ref = context.lookup("java:/comp/env/student");
      //look up jndi name and cast to Home interface
      studentHome= (StudentHome) ref;
    }catch(Exception e){e.printStackTrace();}
  }
  public void ejbRemove() {
    /**@todo Complete this method*/
  }
  public void ejbActivate() {
    /**@todo Complete this method*/
  }
  public void ejbPassivate() {
    try{
     Context context = new InitialContext();

       //look up jndi name
       Object ref = context.lookup("java:/comp/env/student");
       //look up jndi name and cast to Home interface
       studentHome= (StudentHome) ref;
     }catch(Exception e){e.printStackTrace();}

  }
  public void setSessionContext(SessionContext sessionContext) {
    this.sessionContext = sessionContext;
  }
  public String getStuInfo(String stuid){
 String strStu=null;
    try{
    student = studentHome.findByPrimaryKey(new Integer(stuid));
    strStu ="the studentID is "+ student.getStuid() + " Name is "+student.getStuname();
  }catch(Exception e){}
    return strStu;
  }
}

⌨️ 快捷键说明

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