开发者

what would be java.naming.provider.url for tomcat

I m trying to fetch a database connection from a tomcat server using Jndi. In that case what would be my java.naming.provider.url 开发者_开发技巧in case of tomcat ??


The question isn't very clear. Per the JNDI documentation, the url property specifies the location of the registry in the format rmi://server:port. So at least when you're initially creating a naming context to bindings for the objects registered in the registry, you need to pass in the location of the registry. You can find sample code here:

// select the registry service provider as the initial context
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");

// specify where the registry is running
env.put(Context.PROVIDER_URL, "rmi://server:1099");

// create an initial context that accesses the registry
Context ctx = new InitialContext(env);

// now, the names stored in registry can be listed
NamingEnumeration enum = ctx.list("");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜