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

📄 ejbldapclient.java

📁 EJB应用开发的源码,是学习EJB的好帮助!EJB应用开发的源码,是学习EJB的好帮助
💻 JAVA
字号:
/* * LdapClient.java */import java.io.*;import java.util.*;import javax.ejb.EJBHome;import javax.naming.*;import javax.rmi.PortableRemoteObject;import org.omg.CORBA.ORB;import java.rmi.RemoteException;import javax.ejb.CreateException;import netscape.ldap.*;public class EjbLdapClient {    public static void main (String args[]) {	if (args.length== 0){	    args = new String[]{"ucmail.umuc.edu","tcruise@umuc.edu", "o=umuc.edu"};	}	else if (args.length<3){	    System.out.println("Usag: EjbLdapClient [ldap-server] [email address] [base DN e.g. o=netscape.com]");	    System.exit(1);	}//else if	Hashtable env = new Hashtable();	// Uncomment if using Weblogic	env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");	env.put(Context.PROVIDER_URL, "t3://localhost:7001");	// Uncomment if using Websphere	//env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory");	//env.put(Context.PROVIDER_URL, "iiop://localhost:900");	// Uncomment if using JBOSS	//env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");	//env.put("java.naming.provider.url", "localhost:1099");			try {	    System.out.println("looking");	    InitialContext ic = new InitialContext();	    	    System.out.println("Got Initial context");	    	    EjbLdapHome ldaphome = (EjbLdapHome)  PortableRemoteObject.narrow(ic.lookup("HelloWorldLdap.EjbLdap"), EjbLdapHome.class);	    	    if ( null == ldaphome ){ System.out.println("couldn't find the Bean home interface");	    System.exit(1);}	    EjbLdap ldap = (EjbLdap)javax.rmi.PortableRemoteObject.narrow( ldaphome.create(),EjbLdap.class);	    ldap.getConnected(args[0],389);	    Hashtable mytable=ldap.getHashedEntry(args[1], args[2]);	    Enumeration keys=mytable.keys();	    String key;	    while (keys.hasMoreElements()){		key=keys.nextElement().toString();		System.out.print(" key is " +key);		String[]val=(String[])mytable.get(key);		for(int i=0;i<val.length;i++){		    System.out.println("\t"+val[i]);		}//for	    }//while	    	} catch (NamingException e) {	    System.out.println("Naming Exception");	    System.out.println("thisi is a naming exception");	    System.out.println("Explanation " + e.getExplanation());	    System.out.println("Resolved name : " + e.getResolvedName());	    System.out.println("RemainingName " + e.getRemainingName());	    System.out.println("Root Cause: " + e.getRootCause());	} catch (RemoteException e) {	    System.out.println("Heya Remote Exception");	    System.out.println(e);	    e.printStackTrace();	} catch (CreateException e) {	    System.out.println("Create Exception");	} catch (Exception e) {	    e.printStackTrace();	}    }}

⌨️ 快捷键说明

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