Tomcat5.5的Mysql连接池配置 1、下载mysql-connector-java-5.0.6-bin.jar文件并放入到Tomcat的common/lib文件夹2、配置Tomcat的conf/server.xml,在其中增加如下代码: <Resource name="jdbc/mysql" type="javax.sql.DataSource" password="ajax" driverClassName="com.mysql.jdbc.Driver" maxIdle="5" maxWait="5000" validationQuery="select 1" username="ajax" url="jdbc:mysql://localhost:3306/ajax" maxActive="15" /> 3、配置项目的web.xml(WEB-INF目录)文件,增加如下代码: <resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/mysql</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> 4、配置项目的context.xml(META-INF目录)文件,增加如下代码: 可能最初没有此文件,那就创建吧,记得头上加上XML的声明 <?xml version="1.0" encoding="UTF-8"?> <Context> <ResourceLink name="jdbc/mysql" type="javax.sql.DataSource" global="jdbc/mysql" /> </Context> 5、测试配置,在Servlet中加入: Context env = null; try { env = (Context) new InitialContext().lookup("java:comp/env"); pool = (DataSource)env.lookup("jdbc/mysql"); if(pool==null) System.err.println("'DBPool' is an unknown DataSource"); } catch(NamingException ne) { ne.printStackTrace