Topic: 使用数据源时遇到的问题(NameNotFoundException),请帮忙看一下,谢谢!!! |
Print this page |
1.使用数据源时遇到的问题(NameNotFoundException),请帮忙看一下,谢谢!!! | Copy to clipboard |
Posted by: eponpanda Posted on: 2006-07-26 20:10 我使用的是weblogic8.1,配置了连接池和数据源,其中数据源的JNDI是jdbc/bn,在jsp中使用该数据源时出现问题,现将jsp程序和出现的异常 贴在后面,请各位帮忙看一下,谢谢!!!! jsp程序: <%@ page contentType="text/html; charset=gb2312" %> <%@ page import="javax.naming.Context"%> <%@ page import="javax.sql.DataSource"%> <%@ page import="javax.naming.InitialContext"%> <%@ page import="java.sql.*"%> <% DataSource ds = null; try{ Context initCtx = new InitialContext(); Context envCtx = (Context)initCtx.lookup("java:comp/env"); ds = (DataSource)envCtx.lookup("jdbc/bn"); if(ds != null){ out.println("已经获得datasource!"); out.println("<br>"); Connection con = ds.getConnection(); Statement stmt=con.createStatement(); ResultSet rst=stmt.executeQuery("select * from contact"); while(rst.next()){ out.println("<br>userName:" + rst.getString("userName") + "</br>"); } } else{ out.println("连接失败!"); } }catch(Exception e){ e.printStackTrace(); } %> 异常: <2006-7-26 下午17时09分08秒 CST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) Client VM Version 1.4.1_05-b01 from Sun Microsystems Inc.> <2006-7-26 下午17时09分09秒 CST> <Info> <Configuration Management> <BEA-150016> <This server is being started as the administration server.> <2006-7-26 下午17时09分09秒 CST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 8.1 SP2 Fri Dec 5 15:01:51 PST 2003 316284 WebLogic XMLX Module 8.1 SP2 Fri Dec 5 15:01:51 PST 2003 316284 > <2006-7-26 下午17时09分09秒 CST> <Notice> <Management> <BEA-140005> <Loading domain configuration from configuration repository at G:\weblogic\user_projects\domains\libdomain\.\config.xml.> javax.naming.NameNotFoundException: While trying to look up jdbc/bn in java:comp/env.; remaining name 'jdbc/bn' at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:858) at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:150) at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:237) at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:336) at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45) at jsp_servlet.__conpool._jspService(__conpool.java:143) at weblogic.servlet.jsp.JspBase.service(JspBase.java:33) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:446) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170) |
2.Re:使用数据源时遇到的问题(NameNotFoundException),请帮忙看一下,谢谢!!! [Re: eponpanda] | Copy to clipboard |
Posted by: why213344 Posted on: 2006-07-27 15:42 While trying to look up jdbc/bn in java:comp/env.; remaining name 'jdbc/bn' 好像是JNDI的名字都没有找到,你应该好好看看你的数据源配置! |
3.Re:使用数据源时遇到的问题(NameNotFoundException),请帮忙看一下,谢谢!!! [Re: eponpanda] | Copy to clipboard |
Posted by: 潇潇 Posted on: 2006-08-10 16:50 应在web.xml中配置如下: <resource-ref> <res-ref-name>jdbc/bn</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |