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

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

Introduction

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

Prototype

@Override
    public void setProperties(Properties properties) 

Source Link

Usage

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

License:Apache License

/**
 * ?SqlSession//from  w  ww  .  jav  a  2  s.  com
 * @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);
}