六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 89|回复: 0

Tomcat5.5配置多数据源

[复制链接]

升级  38%

3

主题

3

主题

3

主题

童生

Rank: 1

积分
19
 楼主| 发表于 2013-1-13 19:00:28 | 显示全部楼层 |阅读模式
以Tomcat5.5:
(一)在apache-tomcat-5.5\conf的context.xml文件的<Context></Context>元素中:
       <Resource name="jdbc/mysql1" auth="Container" type="javax.sql.DataSource"
             maxActive="50" maxIdle="30" maxWait="10000" logAbandoned="true"
             username="root" password="123456" driverClassName="com.mysql.jdbc.Driver"
             url="jdbc:mysql://localhost:3306/dbmy"/>
   <Resource name="jdbc/mysql2" auth="Container" type="javax.sql.DataSource"
             maxActive="50" maxIdle="30" maxWait="10000" logAbandoned="true"
             username="root" password="123456" driverClassName="com.mysql.jdbc.Driver"
             url="jdbc:mysql://localhost:3306/mydb"/>  
(二)在web.xml中:
          <resource-ref>
  <description>DB1 Connection</description>
  <res-ref-name>jdbc/mysql1</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
   <description>DB2 Connection</description>
   <res-ref-name>jdbc/mysql2</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
</resource-ref>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表