如何为 JNDI InitialContext 的 PROVIDER_URL 指定驱动器号(Windows)
我正在使用基于 com.sun.jndi.fscontext.RefFSContextFactory 文件的 JNDI 上下文工厂。它似乎采用了启动java应用程序的驱动器。
Hashtable properties = new Hashtable(2);
properties.put(Context.PROVIDER_URL,"file:///tmp/jms/mycontext");
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
InitialContext ctx = new InitialContext(properties);
如何指定驱动器号,例如 d:/tmp/jms/mycontext
? 使用 file://d:/tmp/jms/mycontext
似乎仍然转到我系统上的 c 驱动器
I am using the com.sun.jndi.fscontext.RefFSContextFactory
file based JNDI context factory. It seems to take the drive of the where the java application is started in.
Hashtable properties = new Hashtable(2);
properties.put(Context.PROVIDER_URL,"file:///tmp/jms/mycontext");
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
InitialContext ctx = new InitialContext(properties);
How can I specify the drive letter such as d:/tmp/jms/mycontext
?
Using file://d:/tmp/jms/mycontext
seems to still go to the c drive on my system
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
经过一些故障排除和自己调试后,我弄清楚了。在驱动器号前使用额外的 \ 解决它
After some troubleshooting and debugging myself I figured it out. Using an extra \ before the drive letter solves it
像这样:
"file:D:\\tmp\\jms\\mycontext"
developerWorks 教程中的一些示例可能有用:
IBM WebSphere Developer Technical Journal:在 WebSphere MQ V6.0 上运行独立 Java 应用程序
Like so:
"file:D:\\tmp\\jms\\mycontext"
There are some examples in a tutorial at developerWorks that may be useful:
IBM WebSphere Developer Technical Journal: Running a standalone Java application on WebSphere MQ V6.0
“file:///D:/temp”
为我工作"file:///D:/temp"
worked for me