1. 在tomcat目录下conf/context.xml文件中 加入一下代码
<Resource name="jdbc/sqlconnpool"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://192.168.90.17:1433;databaseName=aiclubwg"
username="sa"
password="123456"
maxActive="100" //连接池的最大数据库连接数,设为0表示无限制
maxIdle="30" //最大空闲数,设为0表示无限制
maxWait="10000"/> //最大连接等待时间.如果超时将接到异常.设为 -1 表示无限制
2. 把数据库连接jar包加入 tomcat_HOME/lib 目录下
3. 在web.xml文件中加入
<!-- tomcat 数据库连接池 -->
<resource-ref>
<description>DB Connection Pool</description>
<res-ref-name>jdbc/sqlconnpool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
转载于:https://www.cnblogs.com/justinchinawz/archive/2012/08/16/2641593.html