gpt4 book ai didi

java - 如何为 JNDI InitialContext 的 PROVIDER_URL 指定驱动器号(windows)

转载 作者:可可西里 更新时间:2023-11-01 09:35:47 24 4
gpt4 key购买 nike

我正在使用基于 JNDI 上下文工厂的 com.sun.jndi.fscontext.RefFSContextFactory 文件。它似乎占用了 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 盘

最佳答案

在我自己进行一些故障排除和调试之后,我弄明白了。在盘符前加一个\就解决了

properties.put(Context.PROVIDER_URL,"file://\\d:\\tmp\\mycontext");

关于java - 如何为 JNDI InitialContext 的 PROVIDER_URL 指定驱动器号(windows),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3688132/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com