码迷,mamicode.com
首页 > 其他好文 > 详细

Mybatis c3p0 整合

时间:2015-09-23 06:33:58      阅读:340      评论:0      收藏:0      [点我收藏+]

标签:

1、下载c3p0

2、实现 UnpooledDataSourceFactory

package com.joinhealth.esb.db;

import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory;

import com.mchange.v2.c3p0.ComboPooledDataSource;

public class C3P0DataSourceFactory extends UnpooledDataSourceFactory {

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

}

3、Mybatis-config.xml 配置

 <dataSource type="com.joinhealth.esb.db.C3P0DataSourceFactory">
        <property name="driverClass" value="com.mysql.jdbc.Driver"/>
        <property name="jdbcUrl" value="jdbc:mysql://192.168.10.101:3306/esb?useUnicode=true&amp;characterEncoding=UTF-8"/>
        <property name="user" value="root"/>
        <property name="password" value=""/>
        <property name="idleConnectionTestPeriod" value="60" />
        <property name="maxPoolSize" value="20" />
        <property name="maxIdleTime" value="600" />
</dataSource>

更多 c3p0 配置参数请到 http://www.mchange.com/projects/c3p0/index.html#configuration_properties

Mybatis c3p0 整合

标签:

原文地址:http://www.cnblogs.com/linjian/p/4831066.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!