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

📄 startstudentclient.java

📁 java的一系列产品中包括jsme,jmse,j2ee,本文件提供j2ee实现的源代码.
💻 JAVA
字号:
package sessionEntity;

import java.math.BigDecimal;
//import java.rmi.*;
import java.util.*;
import javax.ejb.*;
//import javax.naming.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

public class StartStudentClient{	
	private static final String JNDI_NAME = "StartStudentEJB";
	private static final String url  = "t3://localhost:7001";	
  public static void main(String[] args){
    try{
      // Get an InitialContext
      Properties env = new Properties();
      env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
      env.put(Context.PROVIDER_URL, url);
      
      Context ctx = new InitialContext(env);      
      Object h=ctx.lookup(JNDI_NAME);
      StartStudentHome startstudenthome=(StartStudentHome)
        	PortableRemoteObject.narrow(h,StartStudentHome.class);
      StartStudent startstudent =startstudenthome.create();
      
      String theStudent=startstudent.HelloStudent();
      System.out.println("My SessionEJB said:"+theStudent);
      
      System.out.println("Finding All the Students in grade 2:");    
    	try {
      	Collection c = startstudent.getAllStudents(2);
      	if (c.isEmpty()) {
        	System.err.println("No Students were found in grade 2.");
      	} else {
        	Iterator it = c.iterator();
        	while (it.hasNext()) {
          	Student s =(Student)PortableRemoteObject.narrow(it.next(),Student.class);
          	System.err.println("Found student named: "+s.getName()+
            	" in grade 2.");
        	}        	
      	}
    	} catch (Exception e) {
      	System.err.println("Unable to find students in grade 2.");
      	//e.printStackTrace();
      	//throw e;
    	}
    }catch(Exception ex) {
      System.err.println("Caught an unexpected exception!");      
    }
 } 
} 

⌨️ 快捷键说明

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