当前位置: 首页>>代码示例>>Java>>正文


Java UnpooledDataSourceFactory.setProperties方法代码示例

本文整理汇总了Java中org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory.setProperties方法的典型用法代码示例。如果您正苦于以下问题:Java UnpooledDataSourceFactory.setProperties方法的具体用法?Java UnpooledDataSourceFactory.setProperties怎么用?Java UnpooledDataSourceFactory.setProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory的用法示例。


在下文中一共展示了UnpooledDataSourceFactory.setProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testConfiguration

import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory; //导入方法依赖的package包/类
@Test
public void testConfiguration() {
    UnpooledDataSourceFactory dataSourceFactory = new UnpooledDataSourceFactory();
    Properties dataSourceProperties = new Properties();
    dataSourceProperties.put("driver", "org.hsqldb.jdbcDriver");
    dataSourceProperties.put("url", "jdbc:hsqldb:mem:xml_references");
    dataSourceProperties.put("username", "sa");
    dataSourceFactory.setProperties(dataSourceProperties);
    Environment environment = new Environment("test", new JdbcTransactionFactory(), dataSourceFactory.getDataSource());
    Configuration configuration = new Configuration();
    configuration.setEnvironment(environment);
    configuration.getTypeAliasRegistry().registerAlias(Person.class);
    configuration.addMapper(PersonMapper.class);
    configuration.addMapper(PersonMapper2.class);
    new DefaultSqlSessionFactory(configuration);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:17,代码来源:EnumWithOgnlTest.java

示例2: getSqlSessionFactoryWithConstructor

import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory; //导入方法依赖的package包/类
private SqlSessionFactory getSqlSessionFactoryWithConstructor() {
    UnpooledDataSourceFactory unpooledDataSourceFactory = new UnpooledDataSourceFactory();
    Properties properties = new Properties();
    properties.setProperty("driver", "org.hsqldb.jdbcDriver");
    properties.setProperty("url", "jdbc:hsqldb:mem:extends_with_constructor");
    properties.setProperty("username", "sa");
    unpooledDataSourceFactory.setProperties(properties);
    Environment environment = new Environment("extends_with_constructor", new JdbcTransactionFactory(), unpooledDataSourceFactory.getDataSource());
    
    Configuration configuration = new Configuration();
    configuration.setEnvironment(environment);
    configuration.addMapper(StudentConstructorMapper.class);
    configuration.addMapper(TeacherMapper.class);
    configuration.getMappedStatementNames();
    configuration.setAutoMappingBehavior(AutoMappingBehavior.NONE);
    
    return new DefaultSqlSessionFactory(configuration);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:19,代码来源:NpeExtendsTest.java


注:本文中的org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory.setProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。