META-INF中加入配置文件context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true" crossContext="true">
<ResourceLink name="jdbc/mysql" global="jdbc/dbcp/mysql/项目" type="java.sql.DataSource"></ResourceLink>
</Context>
Spring配置文件中加入
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/mysql" />
</bean>
Tomcat的server.xml中加入
<Resource acquireIncrement="5" auth="Container" driverClass="com.mysql.jdbc.Driver" factory="org.apache.naming.factory.BeanFactory" initialPoolSize="10" jdbcUrl="jdbc:mysql://localhost:3306/数据库名" maxIdleTime="120" maxPoolSize="300" maxStatements="1000" minPoolSize="10" name="jdbc/dbcp/mysql/项目" password="root" type="com.mchange.v2.c3p0.ComboPooledDataSource" user="root"/>