Tomcate 配置多个数据源

来源:互联网 发布:淘宝靠谱香水代购 编辑:程序博客网 时间:2024/06/05 23:07

共配置两个地方 web.xml与Tomcat中的conf/context.xml

1.web.xml

<resource-ref>  

<description>DBConnection1</description>  

res-ref-name>demo</res-ref-name> 

<res-type>javax.sql.DataSource</res-type>  

<res-auth>Container</res-auth>  

</resource-ref>  

<resource-ref>  

<description>DBConnection2</description>  

<res-ref-name>jdbc/appdata2</res-ref-name> 

<res-type>javax.sql.DataSource</res-type>  

<res-auth>Container</res-auth>  

</resource-ref>

或者

<init-param>
<param-name>dataSource</param-name>
<param-value>demo,oracle,GBK;cqqx,oracle,GBK</param-value>
</init-param>

2.context.xml

加多个

 <Resource name="demo" 
auth="Container"
type="javax.sql.DataSource"
maxActive="10"
maxIdle="30"
maxWait="10000"
username="gdqx"
password="password"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:workflow" 
/>

0 0
原创粉丝点击