你的jndi服务器到底是什么的呀?
WebSphere:  
Context.INITIAL_CONTEXT_FACTORY  
 "com.ibm.websphere.naming.WsnInitialContextFactory  "  
Context.PROVIDER_URL  
 "iiop://localhost:900  "  
Weblogic:  
Context.INITIAL_CONTEXT_FACTORY  
   "weblogic.jndi.WLInitialContextFactory  "  
Context.PROVIDER_URL  
   "t3://127.0.0.1:7001  "               
 
   J2EE  SDK(J2EE  RI):  
Context.INITIAL_CONTEXT_FACTORY  
   "com.sun.jndi.cosnaming.CNCtxFactory  "  
Context.PROVIDER_URL  
   "iiop://127.0.0.1:1050  "  
 
SilverStream:  
Context.INITIAL_CONTEXT_FACTORY  
 "com.sssw.rt.jndi.AgInitCtxFactory  "  
Context.PROVIDER_URL  
 "sssw://localhost:80  "   
  
OC4J
Context.INITIAL_CONTEXT_FACTORY
"com.evermind.server.rmi.RMIInitialContextFactory"
Context.PROVIDER_URL
"ormi://127.0.0.1/"  
 
JBOSS的:
java.naming.factory.initial
"org.jnp.interfaces.NamingContextFactory"
java.naming.provider.url
"localhost:1099"    
WAS5:
Context.INITIAL_CONTEXT_FACTORY  
 "com.ibm.websphere.naming.WsnInitialContextFactory  "  
Context.PROVIDER_URL  
 "iiop://localhost:2809  "

解决方案 »

  1.   

    zez(鹤清风 为了老婆多挣钱 !)    好,学习
      

  2.   

    谢谢鹤先生,你使我对Context上下文参数有了更进一步的了解。并且,我的测试已经通过
    了InitialContext ctx = new InitialContext(containerEn);这一步,但还是报错,因为
    我没有将逻辑名绑定到这个Context中。请问:我应该如何绑定??
      

  3.   

    你的服务器是什么?
    数据源配置好了吗?
    jndi名字是什么?
    然后直接lookup(jndi name)应该就可以啦.
      

  4.   

    datasource的jndi名没有正确配置。确信配置正确,数据库连接正确
      

  5.   

    我的服务器是:J2EE我以前在tomcat中配置,然后可以用以下方法就可以得到连接:
    DataSource ds = (DataSource)new InitialContext().lookup("java:comp/env/jdbc/MSSQL7.0DB");现在,问题就是在没有配数据源,那我应该如何配呢?还有JNDI名是自己指定?
    还有个问题:使用J2EE和在tomcat中配置,而直接向以上那样调用有什么区别,那一种更有意义?