c3p0连接池基本配置mysql和oracle
c3p0-config.xml
<?xml version="1.0" encoding="UTF-8"?> <c3p0-config> <named-config name="jdbc/mysqlname"> <property name="user">username</property> <property name="password">password</property> <property name="driverClass">com.mysql.jdbc.Driver</property> <property name="jdbcUrl">jdbc:mysql://地址:端口/数据库名?characterEncoding=utf-8</property> <property name="initialPoolSize">3</property> <property name="maxIdleTime">30</property> <property name="maxPoolSize">6</property> <property name="minPoolSize">2</property> </named-config> <named-config name="jdbc/oraclename"> <property name="user">username</property> <property name="password">password</property> <property name="driverClass">oracle.jdbc.driver.OracleDriver</property> <property name="jdbcUrl">jdbc:oracle:thin:@地址:端口:ORCL</property> <!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。--> <property name="initialPoolSize">3</property> <!--最大空闲时间,30秒内未使用则连接被丢弃。若为0则永不丢弃。--> <property name="maxIdleTime">30</property> <!--连接池中保留的最大连接数。--> <property name="maxPoolSize">6</property> <!--连接池中保留的最小连接数 --> <property name="minPoolSize">2</property> </named-config> </c3p0-config>