Example usage for org.apache.ibatis.datasource.pooled PooledDataSourceFactory PooledDataSourceFactory

List of usage examples for org.apache.ibatis.datasource.pooled PooledDataSourceFactory PooledDataSourceFactory

Introduction

In this page you can find the example usage for org.apache.ibatis.datasource.pooled PooledDataSourceFactory PooledDataSourceFactory.

Prototype

public PooledDataSourceFactory() 

Source Link

Usage

From source file:com.itfsw.mybatis.generator.plugins.tools.MyBatisGeneratorTool.java

License:Apache License

/**
 * ?SqlSession/*w w  w  .  j  a v a2 s.c o  m*/
 * @return
 * @throws IOException
 */
public SqlSession getSqlSession() throws IOException, ClassNotFoundException {
    org.apache.ibatis.session.Configuration config = new org.apache.ibatis.session.Configuration();
    config.setCallSettersOnNulls(true); // nullsetter
    config.setMapUnderscoreToCamelCase(true); // ???

    // mapper
    config.addMappers(targetPackage);
    // ??
    PooledDataSourceFactory dataSourceFactory = new PooledDataSourceFactory();
    dataSourceFactory.setProperties(DBHelper.properties);
    DataSource dataSource = dataSourceFactory.getDataSource();
    JdbcTransactionFactory transactionFactory = new JdbcTransactionFactory();

    Environment environment = new Environment("test", transactionFactory, dataSource);
    config.setEnvironment(environment);
    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(config);
    return sqlSessionFactory.openSession(true);
}