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>
高手救命啊
------解决方案--------------------
我今天也遇到了类似问题,不过我用的是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.