📄 jnditest.java
字号:
package rain;
import javax.naming.*;
import java.util.Properties;
public class JNDItest {
public static void main(String[] args)
{
Context ctx=null;
Properties p=new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL,"t3://localhost:7001");
try{
ctx=new InitialContext(p);
String test="JNDI Test example";
ctx.bind("name",test);
String s=(String)ctx.lookup("name");
System.out.println(s);
String str="welcome to you ";
ctx.rebind("name",str);
s=(String)ctx.lookup("name");
System.out.println(s);
}
catch(NamingException e)
{
System.out.println(e.toString());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -