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"/>
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>
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'