use of org.springframework.jdbc.datasource.init.ResourceDatabasePopulator in project spring-framework by spring-projects.
the class AbstractEntityManagerFactoryIntegrationTests method executeSqlScript.
protected void executeSqlScript(String sqlResourcePath) throws DataAccessException {
Resource resource = applicationContext.getResource(sqlResourcePath);
new ResourceDatabasePopulator(resource).execute(this.jdbcTemplate.getDataSource());
}
use of org.springframework.jdbc.datasource.init.ResourceDatabasePopulator in project spring-framework by spring-projects.
the class AbstractTransactionalTestNGSpringContextTests method executeSqlScript.
/**
* Execute the given SQL script.
* <p>Use with caution outside of a transaction!
* <p>The script will normally be loaded by classpath.
* <p><b>Do not use this method to execute DDL if you expect rollback.</b>
* @param sqlResourcePath the Spring resource path for the SQL script
* @param continueOnError whether or not to continue without throwing an
* exception in the event of an error
* @throws DataAccessException if there is an error executing a statement
* @see ResourceDatabasePopulator
* @see #setSqlScriptEncoding
*/
protected void executeSqlScript(String sqlResourcePath, boolean continueOnError) throws DataAccessException {
Resource resource = this.applicationContext.getResource(sqlResourcePath);
new ResourceDatabasePopulator(continueOnError, false, this.sqlScriptEncoding, resource).execute(jdbcTemplate.getDataSource());
}
use of org.springframework.jdbc.datasource.init.ResourceDatabasePopulator in project spring-framework by spring-projects.
the class AbstractTransactionalJUnit4SpringContextTests method executeSqlScript.
/**
* Execute the given SQL script.
* <p>Use with caution outside of a transaction!
* <p>The script will normally be loaded by classpath.
* <p><b>Do not use this method to execute DDL if you expect rollback.</b>
* @param sqlResourcePath the Spring resource path for the SQL script
* @param continueOnError whether or not to continue without throwing an
* exception in the event of an error
* @throws DataAccessException if there is an error executing a statement
* @see ResourceDatabasePopulator
* @see #setSqlScriptEncoding
*/
protected void executeSqlScript(String sqlResourcePath, boolean continueOnError) throws DataAccessException {
Resource resource = this.applicationContext.getResource(sqlResourcePath);
new ResourceDatabasePopulator(continueOnError, false, this.sqlScriptEncoding, resource).execute(jdbcTemplate.getDataSource());
}
use of org.springframework.jdbc.datasource.init.ResourceDatabasePopulator in project spring-framework by spring-projects.
the class PrimaryTransactionManagerTests method transactionalTest.
@Test
@Transactional
public void transactionalTest() {
TransactionTestUtils.assertInTransaction(true);
ClassPathResource resource = new ClassPathResource("/org/springframework/test/context/jdbc/data.sql");
new ResourceDatabasePopulator(resource).execute(jdbcTemplate.getDataSource());
assertNumUsers(1);
}
use of org.springframework.jdbc.datasource.init.ResourceDatabasePopulator in project vladmihalcea.wordpress.com by vladmihalcea.
the class DatabaseScriptLifecycleHandler method createResourceDatabasePopulator.
protected ResourceDatabasePopulator createResourceDatabasePopulator() {
ResourceDatabasePopulator resourceDatabasePopulator = new ResourceDatabasePopulator();
resourceDatabasePopulator.setCommentPrefix(getCommentPrefix());
resourceDatabasePopulator.setContinueOnError(isContinueOnError());
resourceDatabasePopulator.setIgnoreFailedDrops(isIgnoreFailedDrops());
resourceDatabasePopulator.setSqlScriptEncoding(getSqlScriptEncoding());
return resourceDatabasePopulator;
}
Aggregations