在网页中显示的错误为:Name jdbc is not bound in this Context
代码如下:
<%@page import="java.io.*" %>
<%@page import="java.util.*" %>
<%@page import="java.sql.*" %>
<%@page import="javax.sql.*" %>
<%@page import="javax.naming.*" %>
<html>
<head>
<title>accessDataSource</title>
</head>
<body>
<%
try{
Connection con;
Statement stmt;
ResultSet rs;
Context ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("java:comp/env/jdbc/text");
con=ds.getConnection();
stmt=con.createStatement();
stmt.executeUpdate("insert into BOOKS(ID,NAME,TITLE,PRICE) values ('555','555','555',44.5)");
rs=stmt.executeQuery("select ID,NAME,TITLE,PERICE from BOOKS");
out.println("<table border=1 width=400>");
while(rs.next()){
String col1=rs.getString(1);
String col2=rs.getString(2);
String col3=rs.getString(3);
float col4=rs.getFloat(4);
col1=new String(col1.getBytes("ISO-8859-1"),"GB2312");
col2=new String(col2.getBytes("ISO-8859-1"),"GB2312");
col3=new String(col3.getBytes("ISO-8859-1"),"GB2312");
out.println("<tr><td>"+col1+"</td><td>"+col2+"</td><td>"+col3+"</td><td>"+col4+"</td></tr>");
}
out.println("</table>");
stmt.executeUpdate("delete from BOOKS where ID='555'");
rs.close();
stmt.close();
con.close();
}catch (Exception ee){
out.println(ee.getMessage());ee.printStackTrace();
}
%>
</body>
</html>
在web.xml中代码如下:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/text</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
在context.xml中代码如下:
<Context reloadable="true">
<Resource name="jdbc/text" auth="Container" tyep="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="text" password="text"
dricerClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:orcl"
/>
</Context>
Myeclipse显示:javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
请高手指教是什么问题,多谢了
相关推荐
数据池连接Name jdbc is not bound in this Context解决方案
配置tomcat7sqlserver数据连接池java 利用数据源对象建立数据库连接时的错误: Name jdbc is not bound in this Context 解决方案
SSM员工信息管理系统:从三层架构到部署实战全解析
在Java Web开发中,SSM组合(Spring+SpringMVC+MyBatis)是经典的三层架构,它将请求处理、业务逻辑与SQL映射解耦,让开发者能清晰维护代码。通过配置文件可以厘清三个框架的分工,理解一次请求从Controller到Mapper再到JSP的完整链路。以员工信息管理系统为例,这类项目覆盖了CRUD、分页、表单回显等典型场景,是很多计算机专业毕业设计的选题。掌握从Maven依赖、web.xml、SpringMVC视图解析到MyBatis映射的配置方法,再结合MySQL建表与Tomcat
Tomcat启动时报错:Name salesDataSource is not bound in this Context
Name salesDataSource is not bound in this Context,连接池的问题
struts1中所遇到的配置问题
这是在struts1的练习中总结出来的错误,然后找各种的资料得到了如下的总结,希望帮到有需要的程序猿。错误原现: Name jdbc is not bound in this Context Cannot create JDBC driver of class '' for connect URL 'null'
struts2开发遇到的问题
strut2开发中我们所遇到的问题和相对应的一些有用的解决方法,


Web 开发
