java获取weblogic8中的连接报错
Context ctx = null;
String url = null;
String user = null;
String password = null;
Properties properties = null;
Connection conn = null;
url = "t3://localhost:7001";
user = "weblogic";
password = "weblogic";
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS,
password == null ? "" : password);
}
ctx = new InitialContext(properties);
DataSource ds = (DataSource) ctx.lookup("rmsdatasource");
System.out.println(ds);
conn =
ds.getConnection(); 这个地方报错
String sql = "select count(*) from dual";
int count = 0;
count = conn.createStatement().executeUpdate(sql);
System.out.println("count ====" + count);
------解决方案--------------------你查看一下jndi树吧,要么名字错了,要么少了个类似namespace的属性