轉(zhuǎn)載網(wǎng)址: http://blog.sina.com.cn/s/blog_53803b7b010144u5.html
?關(guān)于在TOMCAT下配置多數(shù)據(jù)源,網(wǎng)上有很多方式,但是感覺也很混亂,俺只說俺們使用的并且經(jīng)過測試可用的方法,修改兩個文件,web.xml和context.xml,這兩個文件都可以在TOMCAT的conf文件夾下找到.
?(這里演示了MYSQL和SQLSERVER數(shù)據(jù)源的配置,其它數(shù)據(jù)庫以此類推)
??1.在WEB.XML最后增加下面內(nèi)容,以此類推,有多少數(shù)據(jù)源就增加多少個resource-ref
<resource-ref> ?????
<description>DBConnection1</description> ?????
<res-ref-name>jdbc/appdata1</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>
??2.在CONTEXT.XML最后增加下面內(nèi)容,以此類推,有多少數(shù)據(jù)源就增加多少個Resource
???<Resource name="jdbc/appdata1" ?????auth="Container" ?????type="javax.sql.DataSource" ?????driverClassName="com.mysql.jdbc.Driver" ?????url="jdbc:mysql://127.0.0.1/databasename" ?????username="root" ?????password="password" ?????maxActive="100" ?????maxIdle="30" ???maxWait="10000"/>
???<Resource name="jdbc/appdata2" ?????auth="Container" ?????type="javax.sql.DataSource" ?????driverClassName="net.sourceforge.jtds.jdbc.Driver" ?????url="jdbc:jtds:sqlserver://127.0.0.1:1433/databasename" ?????username="sa" ?????password="password" ?????maxActive="100" ?????maxIdle="30" ???maxWait="10000"/>? ??
?這么設(shè)置完重新啟動TOMCAT就可以了.
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
