List of usage examples for org.apache.ibatis.jdbc ScriptRunner setStopOnError
public void setStopOnError(boolean stopOnError)
From source file:org.mybatis.guice.sample.SampleBasicTest.java
License:Apache License
@BeforeEach public void setupMyBatisGuice() throws Exception { // bindings//from w w w .ja va 2s . c o m this.injector = createInjector(new MyBatisModule() { @Override protected void initialize() { install(JdbcHelper.HSQLDB_IN_MEMORY_NAMED); bindDataSourceProviderType(PooledDataSourceProvider.class); bindTransactionFactoryType(JdbcTransactionFactory.class); addMapperClass(UserMapper.class); bindProperties(binder(), createTestProperties()); bind(FooService.class).to(FooServiceMapperImpl.class); } }); // 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.SampleSqlSessionTest.java
License:Apache License
@BeforeEach public void setupMyBatisGuice() throws Exception { // bindings// w ww .ja v a2s . c om 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);/*from w w w . jav a 2s. c om*/ 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(); }
From source file:org.sonar.core.persistence.DdlUtils.java
License:Open Source License
private static ScriptRunner newScriptRunner(Connection connection) { ScriptRunner scriptRunner = new ScriptRunner(connection); scriptRunner.setDelimiter(";"); scriptRunner.setStopOnError(true); scriptRunner.setLogWriter(new PrintWriter(new NullWriter())); return scriptRunner; }