List of usage examples for org.apache.ibatis.datasource.pooled PooledDataSourceFactory setProperties
@Override public void setProperties(Properties properties)
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); }