Mybatis兼容C3P0连接池

一。

  

package com.imooc.mybatis.datasource;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory;

/**
 * mybatis和c3p0兼容
 */
public class C3P0DatasourceFactory extends UnpooledDataSourceFactory {

    public C3P0DatasourceFactory(){
        this.dataSource = new ComboPooledDataSource();
    }
}

二。

  

    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
<!--            <dataSource type="POOLED">-->
                <!--换c3p0的源-->
                <dataSource type="com.imooc.mybatis.datasource.C3P0DatasourceFactory">
                <property name="driverClass" value="${driverClass}"/>
                <property name="jdbcUrl" value="${jdbcUrl}"/>
                <property name="user" value="${user}"/>
                <property name="password" value="${password}"/>
            </dataSource>
        </environment>
    </environments>

 

posted @ 2020-10-19 14:33  python成长中  阅读(190)  评论(0编辑  收藏  举报