Eclipse运行JSP文件出现javax.naming.NameNotFoundException: Name jdbc is not bound in this Context?

如题。请教怎么解决?
还有个问题怎么解决java.lang.OutOfMemoryError: PermGen space?
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import= "java.sql.* "%>
<%@ page import= "javax.naming.* "%>
<%
try{
Context initCtx = new InitialContext();
Context ctx = (Context) initCtx.lookup("java:comp/env");
//获取连接池对象
Object obj = (Object) ctx.lookup("jdbc/sqlserver");
//类型转换
javax.sql.DataSource ds = (javax.sql.DataSource)obj;
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
String strSql = "SELECT * FROM userTable";
ResultSet rs = stmt.executeQuery(strSql);

在web.xml中配置如下:
<resource-ref>
<res-ref-name>数据库名</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
在tomcat中配置如下:
<Context path="/web的根目录名">
<Resource name="数据库名"
type="javax.sql.DataSource"
username="root"
password="root"
driverClassName="com.mysql.jdbc.Driver"
maxIdle="10"
url="jdbc:mysql://localhost:3306/tarena"
maxActive="10"/>
</Context>
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-07-13
Name jdbc is not bound in this Context 连接池配错了!
java.lang.OutOfMemoryError: PermGen space 这个问题为内存溢出, 重启下服务就可以。
第2个回答  2010-07-12
数据库连接的驱动有问题。
第3个回答  2010-07-12
如果你连接数据库的数据库名字没写错的话
应该是数据库驱动语句写的有问题吧
把你连接数据库的几句帖出来看看