tomcat 6配置sqlserver数据源(连接池)

1.1修改tomcat的conf文件夹下的context.xml配置文件
[code lang=”xml” highlight=”0,16-22”]

<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>

<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->

<!-- Uncomment this to enable Comet connection tacking (provides events
     on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->

1
2
3
4
5
6
7
8
9
<!--more-->
1.2在项目的web.xml中加入资源引用
[code lang="xml"]
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

1.3 spring中使用数据源
[code lang=”xml”]
java:comp/env/jdbc/TestDB
```