1、修改C:\apache-tomcat-6.0.20\conf\context.xml文件,增加
<Resource name="jdbc/mysql_pool" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="密码" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/projects?autoReconnect=true"/>
![clip_image002 clip_image002](http://www.cppblog.com/images/cppblog_com/woaidongmao/WindowsLiveWriter/Tomcat6.0.20_C16A/clip_image002_thumb.jpg)
2、修改D:\java projects\tiesuanpan\WebRoot\META-INF\web.xml文件,增加
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/mysql_pool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
![clip_image004 clip_image004](http://www.cppblog.com/images/cppblog_com/woaidongmao/WindowsLiveWriter/Tomcat6.0.20_C16A/clip_image004_thumb.jpg)
3、如果“mysql-connector-java-5.1.7-bin.jar”不在Tomcat的lib文件夹下,需要拷贝进去,否则会报错:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'