Tomcat5.5X连接池(dbcp)

容器:Tomcat 5.5X
数据库:MySql5.0
  主要涉及几个目录,几个文件,如下
*  以下配置根据自己实际情况修改~
__________________________
1    Tomcat 安装目录/conf下/server.xml
在server.xml中~在<Context>里添加
<Resource auth="Container" name="jdbc/pure" type="javax.sql.DataSource" username="root" password="5200" driverClassName="org.gjt.mm.mysql.Driver" maxIdle="2" maxWait="5000" url="jdbc:mysql://localhost:3306/pure" maxActive="4"/>
 
 
2    Tomcat 安装目录/conf/Catalina/localhost  下新建一个与你工程文件夹一样名字的xml
比如你webapps下的工程名为test,那么就在Tomcat 安装目录/conf/Catalina/localhost  新建一个text.xml ,加入内容:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
 <Resource
      name="jdbc/pure"
      type="javax.sql.DataSource"
      password="5200"
      driverClassName="org.gjt.mm.mysql.Driver"
      maxIdle="2"
      maxWait="5000"
      username="root"
      url="jdbc:mysql://localhost:3306/pure"
      maxActive="4"/>
</Context>
3    项目工程中的web.xml
<resource-ref>
   <description>DB Connection</description>
  <res-ref-name>jdbc/pure</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
 </resource-ref>
 
__________________________________________
经常报的一些异常说以下
*  Cannot create JDBC driver of class '' for connect URL 'null'
1  检查驱动放到tomcat 目录/conmm/lib 下没
2  检查server.xml正不正确~或者用了版本不同的配置方法,所以没认到
3  在 /conf/Catalina/localhost  新建了xml没~确认一下参数
 
*  javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
  1  直接确认是不是没有在web.xml加入相应内容
<resource-ref>
   <description>DB Connection</description>
  <res-ref-name>jdbc/pure</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
 </resource-ref>

本文出自 “Pure 纯粹--热衷于技术..” 博客,请务必保留此出处http://973007.blog.51cto.com/100031/62943

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值