tomcat 5.5.17 + oracle 10g + dreamweaver 8 连接池问题
tomcat 5.5.17 + oracle 10g + dreamweaver 8 连接池问题
我在网上搜索了一些,现在是这么配的:
一、把驱动 ojdbc14.jar 放到 %tomcat根目录%/common/lib 下
二、打开 %tomcat根目录%/conf/context.xml ,在<Context></Context>标签之间插入:
<Resource
name="jdbc/oracle"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
password="xk"
maxIdle="30"
maxWait="5000"
username="scott"
url="jdbc:oracle:thin:@localhost:1521:orcl"
maxActive="20"/>
三、测试程序(一个JSP文件中相关的部分):
<%
try
{
Context initCtx = new InitialContext();
Context ctx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)ctx.lookup("jdbc/oracle");
Connection con=ds.getConnection();
//Class.forName("oracle.jdbc.driver.OracleDriver");
//Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL", "scott", "xk");
if (con != null)
System.out.println("连接成功!");
}catch(Exception e)
{
e.printStackTrace();
}
%>
现在这样运行会产生异常:
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
但如果运行不使用连接池的版本,即把被注释的两行恢复未被注释,并将其上四行注释掉,是成功的。
请问我是哪里做错了呢?谢谢!