Example usage for org.apache.ibatis.jdbc ScriptRunner setAutoCommit

List of usage examples for org.apache.ibatis.jdbc ScriptRunner setAutoCommit

Introduction

In this page you can find the example usage for org.apache.ibatis.jdbc ScriptRunner setAutoCommit.

Prototype

public void setAutoCommit(boolean autoCommit) 

Source Link

Usage

From source file:org.mybatis.guice.sample.SampleSqlSessionTest.java

License:Apache License

@BeforeEach
public void setupMyBatisGuice() throws Exception {

    // bindings//from   w  ww  .java2  s . co  m
    List<Module> modules = this.createMyBatisModule();
    this.injector = Guice.createInjector(modules);

    // prepare the test db
    Environment environment = this.injector.getInstance(SqlSessionFactory.class).getConfiguration()
            .getEnvironment();
    DataSource dataSource = environment.getDataSource();
    ScriptRunner runner = new ScriptRunner(dataSource.getConnection());
    runner.setAutoCommit(true);
    runner.setStopOnError(true);
    runner.runScript(getResourceAsReader("org/mybatis/guice/sample/db/database-schema.sql"));
    runner.runScript(getResourceAsReader("org/mybatis/guice/sample/db/database-test-data.sql"));
    runner.closeConnection();

    this.fooService = this.injector.getInstance(FooService.class);
}

From source file:org.mybatis.guice.sample.SampleTestBase.java

License:Apache License

private void createTestDb(Injector injector) throws IOException, SQLException {
    // prepare the test db
    Environment environment = injector.getInstance(SqlSessionFactory.class).getConfiguration().getEnvironment();
    DataSource dataSource = environment.getDataSource();

    ScriptRunner runner = new ScriptRunner(dataSource.getConnection());
    runner.setAutoCommit(true);
    runner.setStopOnError(true);/*w w  w . j  av  a  2s .c  om*/
    runner.runScript(getResourceAsReader("org/mybatis/guice/sample/db/database-schema.sql"));
    runner.runScript(getResourceAsReader("org/mybatis/guice/sample/db/database-test-data.sql"));
    runner.closeConnection();
}

From source file:org.wso2.carbon.cluster.utils.DBConnection.java

public static void runScript(Connection con, File sqlFile) throws Exception {
    ScriptRunner runner = new ScriptRunner(con);
    runner.setAutoCommit(true);
    runner.runScript(new BufferedReader(new FileReader(sqlFile)));
}