1. Download c3p0
2. Realize Unpooleddatasourcefactory
Package com.joinhealth.esb.db; Import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory; Import Com.mchange.v2.c3p0.ComboPooledDataSource; Public class extends unpooleddatasourcefactory { public c3p0datasourcefactory () { this New combopooleddatasource (); }}
3. Mybatis-config.xml Configuration
<DataSourcetype= "com.joinhealth.esb.db.C3P0DataSourceFactory"> < Propertyname= "Driverclass"value= "Com.mysql.jdbc.Driver"/> < Propertyname= "Jdbcurl"value= "Jdbc:mysql://192.168.10.101:3306/esb?useunicode=true&characterencoding=utf-8"/> < Propertyname= "User"value= "root"/> < Propertyname= "Password"value=""/> < Propertyname= "Idleconnectiontestperiod"value= "$" /> < Propertyname= "Maxpoolsize"value= " the" /> < Propertyname= "MaxIdleTime"value= "All" /></DataSource>
For more c3p0 configuration parameters, go to http://www.mchange.com/projects/c3p0/index.html#configuration_properties
Mybatis C3P0 Integration