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("");