weblogic8中配置连接池成功了,但是lookup不到?

03-08-29 lyojbuilder
我用的是mysql.

我的连接池jndi name是jdbc/mysql,Datasource和connection pool都测试成功了,但一用jdbc/mysql就报错:"javax.naming.NameNotFoundException: While trying to lookup 'jdbc.mysql' didn't find subcontext 'jdbc' Resolved ; remaining name 'jdbc/mysql' "

即使用了java:comp/env/jdbc/mysql或直接用mysql都包类似这个错误,谁遇到过?

//////////////////////test.jsp/////////////////////////////////

String sql="select * from guestbook";

try{

Context ctx=new InitialContext();

DataSource ds=(DataSource)ctx.lookup("jdbc/mysql");

Connection conn=ds.getConnection();

Statement stm=conn.createStatement();

ResultSet rs=stm.executeQuery(sql);

while(rs.next()){

out.println(rs.getString("id"));

out.println(rs.getString("title"));

out.println(rs.getString("name"));

}

}catch(Exception e){

out.println(e.toString());

}

1
robbin
2003-08-29 23:37
你在Console里面配置JNDI名称的时候应该用:"jdbc.mysql"

lyojbuilder
2003-08-29 23:51
还是不行,问题依旧。总说:javax.naming.NameNotFoundException: While trying to lookup 'jdbc.mysql' didn't find subcontext 'jdbc' Resolved ; remaining name 'jdbc/mysql'

我重启过weblogic了,在6.1中这样是可以的。

lyojbuilder
2003-08-29 23:53
对了,我的代码改成:DataSource ds=(DataSource)ctx.lookup("jdbc.mysql");

或DataSource ds=(DataSource)ctx.lookup("java:comp/env/jdbc.mysql");

或DataSource ds=(DataSource)ctx.lookup("jdbc/mysql");

都不行

lyojbuilder
2003-08-30 00:59
问题解决,用jdbc.mysql,再重启一次机器就莫名其妙的好了。

猜你喜欢