连接池问题:javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

james0210 2007-05-22 06:30:16
Tomcat 5.5 + MySQL 配置的数据库连接池出问题了
是按照网上写的在%TOMCAT_HOME%\conf\Catalina\localhost下创建同项目名称的xml文件
不过还是出现这个错误信息
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
实验室的机器让我稀里糊涂配成功了
寝室的就是不行
xml文件我复制机房的过来也不成
以下是XML文件内容

<Context path="/nbcs" docBase="C:\Tomcat\webapps\nbcs" reloadable="true" crossContext="true" debug="0" >

<Resource name="jdbc/yiyang" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="yiyang" password="123456" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/yiyang?useUnicode=true&characterEncoding=GBK"/>

</Context>

高手救命啊
...全文
11925 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
周末简设 2011-03-04
  • 打赏
  • 举报
回复
参考
http://www.cctieba.cc/tiezi.aspx?tieziId=283
Qyin2009and2010 2010-09-05
  • 打赏
  • 举报
回复
我遇到同样的问题,我错误的原因是username写成了userName
Qyin2009and2010 2010-09-04
  • 打赏
  • 举报
回复
我也遇到同样的问题了~
倾听-csdn 2010-05-07
  • 打赏
  • 举报
回复
楼上的SB,就知道说人家的错了,不知道说答案,白说
unat 2007-05-28
  • 打赏
  • 举报
回复
lz两个错误都是配置错误了
xingkiller 2007-05-28
  • 打赏
  • 举报
回复
我今天也遇到了类似问题,不过我用的是tomcat5.0.27的,配置的语法不太一样,但道理是一样的。出现Name jdbc is not bound in this Context 说明他找不到你写的连接池资源配置文件。如果你把那些配置文件写入server.xml的context中就会出现这个问题。如果你写到<GlobalNamingResources></GlobalNamingResources>之间就会出现org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'这个问题
总结了两种解决方法:
(1)把资源配置写入<GlobalNamingResources></GlobalNamingResources>之间
然后在conf/Catalina/localhost下面建立你的web描述文件比如你的web叫simplebbs你要建立simplebbs.xml在里面写入<?xml version="1.0" encoding="ISO-8859-1"?>
<Context path="/simplebbs" docBase="${catalina.home}/webapps/simplebbs"
debug="0" privileged="true">
<ResourceLink name="jdbc/bbs" global="jdbc/bbs" type="javax.sql.DataSource" />
</Context>
(2)server.xml中的<context></context>之间只写:
<!-- new Context -->
<Context path="simplebbs" docBase="simplebbs"
debug="100" reloadable="true" crossContext="true">

<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_SimpleBBS_log." suffix=".txt"
timestamp="true"/>
</Context>
在conf/Catalina/localhost下面建立你的web描述文件比如你的web叫simplebbs你要建立simplebbs.xml在里面写入
<?xml version="1.0" encoding="ISO-8859-1"?>
<Context path="/simplebbs" docBase="${catalina.home}/webapps/simplebbs"
debug="0" privileged="true">
<Resource name="jdbc/bbs"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/bbs">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>

<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>5</value>
</parameter>

<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>60000</value>
</parameter>

<!-- MSSQLserver dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>sa</value>
</parameter>
<parameter>
<name>password</name>
<value>123</value>
</parameter>

<!-- Class name for mssqlserver JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
</parameter>

<!-- The JDBC connection url for connecting to your mssqlserver dB.-->
<parameter>
<name>url</name>
<value>jdbc:microsoft:sqlserver://192.168.0.11:1433;databasename=bbs;SelectMethod=Cursor</value>
</parameter>
</ResourceParams>
</Context>
shuai45 2007-05-22
  • 打赏
  • 举报
回复
配置的问题或JDBC驱动错误 自己检查一下.
具体原因应该看程序代码
james0210 2007-05-22
  • 打赏
  • 举报
回复
现在又让我不知怎么弄得错误提示改成这个了

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧