日期:2014-05-16  浏览次数:20486 次

使用连接池连接SQL Server2000数据库javax.naming.NameNotFoundException:
点击下面标题查看本文完整版:使用连接池连接SQL Server2000数据库javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

连接池连接SQL Server2000数据库
我想问一下JBuiler使用连接池连接SQL Server2000数据库javax.naming.NameNotFoundException: Name jdbc is not bound in this Context 这是什么问题啊?
我在server.xml上加上了
<Context path="/DBTest" reloadable="true" docBase="${catalina.home}/webapps/DBTest">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_DBTest_log."
suffix=".txt" timestamp="true"/>
<Resource name="jdbc/my_db" auth="Container" type="java.sql.DataSource"/>
<ResourceParams name="jdbc/my_db">
<parameter>
<name>factory </name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory </value>
</parameter>
<parameter>
<name>maxActive </name>
<value>100 </value>
</parameter>
<parameter>
<name>maxIdle </name>
<value>30 </value>
</parameter>
<parameter>
<name>maxWait </name>
<value>10000 </value>
</parameter>
<parameter>
<name>username </name>
<value>sa </value>
</parameter>
<parameter>
<name>password </name>
<value> </value>
</parameter>
<parameter>
<name>driveClassName </name>
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver </value>
</parameter>
<parameter>
<name>url </name>
<value>jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=my_db;user=sa;password=; </value>
</parameter>
</ResourceParams>
</Context>
在tomcat/webapps/DBTest下创建了web.xml,内容如下:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"?

version="2.4">
<description>SQLServer2000 Test APP </description>
<resource-ref>
<description>DB Connection </description>
<res-ref-name>jdbc/my_db </res-ref-name>
<res-type>javax.sql.DataSource </res-type>
<res-auth>Container </res-auth>
</resource-ref>
</web-app>
源程序代码如下: <%@page contentType="text/html;charset=gb2312" language="java" import="java.sql.*,javax.naming.*,javax.sql.*" errorPage=""%>