Web Logic,JAVA,T3:没有初始上下文异常

时间:2013-11-11 09:26:35

标签: java weblogic12c

我得到这个错误我不知道我的代码中缺少什么我是网络逻辑的新手..任何帮助将不胜感激

Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    at com.rest.client.Type4Conn.main(Type4Conn.java:37)
Caused by: java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)

这是我的代码

Properties p=new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL,"t3://http://192.168.1.188:7001/jdbcDataSource");
p.put(Context.SECURITY_PRINCIPAL, username);
p.put(Context.SECURITY_CREDENTIALS, password);

InitialContext ctx=new InitialContext(p);

DataSource ds=(DataSource)ctx.lookup("ds_orclmrcos");  
Connection con=ds.getConnection();
Statement st=con.createStatement();

int a=st.executeUpdate("insert into user values('test','testuser',2)");
System.out.println(a+" records inserted");

link是我的参考..

0 个答案:

没有答案