Search in sources :

Example 11 with UnpooledDataSource

use of org.apache.ibatis.datasource.unpooled.UnpooledDataSource in project mybatis-3 by mybatis.

the class SubstitutionInAnnotsTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    Class.forName("org.hsqldb.jdbcDriver");
    Connection c = DriverManager.getConnection("jdbc:hsqldb:mem:annots", "sa", "");
    Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/substitution_in_annots/CreateDB.sql");
    ScriptRunner runner = new ScriptRunner(c);
    runner.setLogWriter(null);
    runner.setErrorLogWriter(null);
    runner.runScript(reader);
    c.commit();
    reader.close();
    Configuration configuration = new Configuration();
    Environment environment = new Environment("test", new JdbcTransactionFactory(), new UnpooledDataSource("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:annots", null));
    configuration.setEnvironment(environment);
    configuration.addMapper(SubstitutionInAnnotsMapper.class);
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
Also used : UnpooledDataSource(org.apache.ibatis.datasource.unpooled.UnpooledDataSource) Configuration(org.apache.ibatis.session.Configuration) Connection(java.sql.Connection) Reader(java.io.Reader) Environment(org.apache.ibatis.mapping.Environment) SqlSessionFactoryBuilder(org.apache.ibatis.session.SqlSessionFactoryBuilder) ScriptRunner(org.apache.ibatis.jdbc.ScriptRunner) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) BeforeClass(org.junit.BeforeClass)

Example 12 with UnpooledDataSource

use of org.apache.ibatis.datasource.unpooled.UnpooledDataSource in project mybatis-3 by mybatis.

the class ResultMapReferenceTest method getSqlSessionFactoryJavaConfig.

private SqlSessionFactory getSqlSessionFactoryJavaConfig() throws Exception {
    Class.forName("org.hsqldb.jdbcDriver");
    Connection c = DriverManager.getConnection("jdbc:hsqldb:mem:xmlextref", "sa", "");
    initDb(c);
    Configuration configuration = new Configuration();
    Environment environment = new Environment("development", new JdbcTransactionFactory(), new UnpooledDataSource("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:xmlextref", null));
    configuration.setEnvironment(environment);
    configuration.addMapper(ResultMapReferencePersonMapper.class);
    configuration.addMapper(ResultMapReferencePetMapper.class);
    return new SqlSessionFactoryBuilder().build(configuration);
}
Also used : UnpooledDataSource(org.apache.ibatis.datasource.unpooled.UnpooledDataSource) Configuration(org.apache.ibatis.session.Configuration) Connection(java.sql.Connection) Environment(org.apache.ibatis.mapping.Environment) SqlSessionFactoryBuilder(org.apache.ibatis.session.SqlSessionFactoryBuilder) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory)

Aggregations

UnpooledDataSource (org.apache.ibatis.datasource.unpooled.UnpooledDataSource)12 Connection (java.sql.Connection)10 Environment (org.apache.ibatis.mapping.Environment)10 Configuration (org.apache.ibatis.session.Configuration)10 SqlSessionFactoryBuilder (org.apache.ibatis.session.SqlSessionFactoryBuilder)10 JdbcTransactionFactory (org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory)10 Properties (java.util.Properties)2 Reader (java.io.Reader)1 DataSource (javax.sql.DataSource)1 BaseDataTest (org.apache.ibatis.BaseDataTest)1 PooledDataSource (org.apache.ibatis.datasource.pooled.PooledDataSource)1 ScriptRunner (org.apache.ibatis.jdbc.ScriptRunner)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1