weblogic8中配置連線池成功了,但是lookup不到?

lyojbuilder發表於2003-08-29
我用的是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());
}

相關文章