WEB开发网
开发学院WEB开发Jsp JNDI查找示例 阅读

JNDI查找示例

 2008-01-05 08:58:23 来源:WEB开发网   
核心提示:import java.util.*;import javax.naming.*;import javax.naming.Directory.*;import java.io.*;public class ListAll { public static void main(java.lang.String[] arg

import java.util.*;

import javax.naming.*;

import javax.naming.Directory.*;

import java.io.*;

public class ListAll {

   public static void main(java.lang.String[] args) {

     Hashtable env = new Hashtable();

     env.put(Context.INITIAL_CONTEXT_FACTORY,

       "weblogic.jndi.WLInitialContextFactory");

     env.put(Context.PROVIDER_URL, "t3://localhost:7001");

     try {

        InitialContext ctx = new InitialContext(env);

         NamingEnumeration enum = ctx.listBindings("");

        while(enum.hasMore()) {

         Binding binding = (Binding) enum.next();

         Object obj = (Object) binding.getObject();

         System.out.println(obj);

       }

     } catch (NamingException e) {

     System.out.println(e);

     }


Tags:JNDI 查找

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接