首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

tomcat6连接池配备

2012-11-06 
tomcat6连接池配置tomcat6连接池配置前两天安装的Tomcat 6,配置了连接池,可是运行总是报Cannot create JDB

tomcat6连接池配置
tomcat6连接池配置
前两天安装的Tomcat 6,配置了连接池,可是运行总是报  Cannot create JDBC driver of class '' for connect URL 'null' 的错误,URL没有错啊!

上网查了下,Tomcat 6的配置和以前的不同了,不推荐在server.xml中进行配置,而是在context.xml中进行配置才是更好的方法。是站点目录下的context.xml文件,不是tomcat_home\conf下的。tomcat_home\webapps\yourApp\META-INF\context.xml,我的网站目录中没有context.xml,于是创建一个,这样可以在不同的网站下单独配置连接池了,并且不需要重启Tomcat,Tomcat会自动重载。

context.xml例:

<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true" crossContext="true">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
  <Manager pathname="" />
-->
<Resource
name="jdbc/mldb"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.sybase.jdbc3.jdbc.SybDriver"
url="jdbc:sybase:Tds:192.168.0.159:7806/mldb"
username="username"
password="password"
maxActive="20"
maxIdle="10"
maxWait="-1"/>
</Context>



还可以使用全局配置方式(没试过)

第一步:配置tomcat下的conf下的context.xml文件,在之间添加连接池如下:
Xml代码
<Resource
name="jdbc/mldb"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.sybase.jdbc3.jdbc.SybDriver"
url="jdbc:sybase:Tds:192.168.0.159:7806/mldb"
username="username"
password="password"
maxActive="20"
maxIdle="10"
maxWait="-1"/>
</Context>

第二步:配置你的应用下的web.xml中的之间加入:
xml 代码
Xml代码
<resource-ref>   
    <description>DB Connection</description>   
    <res-ref-name>jdbc/mldb</res-ref-name>   
    <res-type>javax.sql.DataSource</res-type>   
    <res-auth>Container</res-auth>   
</resource-ref>   

热点排行