第一種 全局配置
當(dāng)你在Eclipse中添加完tomcat時,那么在Eclipse哪里就有一個servers項目伙菜,在servers項目下的context.xml文件中加入如下代碼锣夹,就可以了
<Resource name = "jdbc/DataSource"
factory = "org.apache.naming.factory.BeanFactory"
type = "com.mchange.v2.c3p0.ComboPooledDataSource"
user="root"
password="123456"
driverClass="com.mysql.jdbc.Driver"
jdbcUrl="jdbc:mysql://127.0.0.1/mydb1"
maxPoolSize="20"
minPoolSize ="5"
initialPoolSize="10"
acquireIncrement="2"
/>
第二種 局部配置
在你web項目下的/WebContent/META-INF目錄下新建content.xml,加入以下代碼就可以了
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name = "jdbc/DataSource"
factory = "org.apache.naming.factory.BeanFactory"
type = "com.mchange.v2.c3p0.ComboPooledDataSource"
user="root"
password="123456"
driverClass="com.mysql.jdbc.Driver"
jdbcUrl="jdbc:mysql://127.0.0.1/mydb1"
maxPoolSize="20"
minPoolSize ="5"
initialPoolSize="10"
acquireIncrement="2"
/>
</Context>