请问这是什么错误???

06-08-26 ppt2006hg

javax.servlet.ServletException: Name jdbc is not bound in this Context

org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)

org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)

org.apache.jsp.views_jsp._jspService(views_jsp.java:114)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

我在TOMCAT里已经弄了数据源jdbc/sDB

我代码是:
<%@ page import="java.sql.*"%>

<%@ page import="javax.sql.*"%> 

<%@ page import="javax.naming.*"%> 

<%@ page import="javax.servlet.http.*"%>

<html>

<body>

<%
 

DataSource ds = null;

Context ctx = new InitialContext();

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

Connection conn = ds.getConnection(); 


Statement stmt = conn.createStatement();

String sql="select * from password";

ResultSet rs=stmt.executeQuery(sql);

while(rs.next()) {%>

您的第一个字段内容为:<%=rs.getString(1)%>
<br>
<br>
您的第二个字段内容为:<%=rs.getString(2)%>

<%}%>
<br>
<br>
<%out.print("数据库操作成功,恭喜你");%>

<%

rs.close();

stmt.close();

conn.close();

%>

</body>

</html>

<p>

banq
2006-08-28 11:02

你使用了JNDI,但是没有在tomcat容器中配置JNDI名称。网上搜索一下。

ppt2006hg
2006-09-07 19:46

谢谢