Search in sources :

Example 16 with ResourceDatabasePopulator

use of org.springframework.jdbc.datasource.init.ResourceDatabasePopulator in project vladmihalcea.wordpress.com by vladmihalcea.

the class DatabaseScriptLifecycleHandler method runInitScripts.

private void runInitScripts() {
    final ResourceDatabasePopulator resourceDatabasePopulator = createResourceDatabasePopulator();
    jdbcTemplate.execute(new ConnectionCallback<Void>() {

        @Override
        public Void doInConnection(Connection con) throws SQLException, DataAccessException {
            resourceDatabasePopulator.setScripts(getInitScripts());
            resourceDatabasePopulator.populate(con);
            return null;
        }
    });
}
Also used : SQLException(java.sql.SQLException) ResourceDatabasePopulator(org.springframework.jdbc.datasource.init.ResourceDatabasePopulator) Connection(java.sql.Connection) DataAccessException(org.springframework.dao.DataAccessException)

Example 17 with ResourceDatabasePopulator

use of org.springframework.jdbc.datasource.init.ResourceDatabasePopulator in project Activiti by Activiti.

the class DatabaseInititializer method databasePopulator.

private DatabasePopulator databasePopulator() {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(schemaScript);
    populator.addScript(dataScript);
    return populator;
}
Also used : ResourceDatabasePopulator(org.springframework.jdbc.datasource.init.ResourceDatabasePopulator)

Aggregations

ResourceDatabasePopulator (org.springframework.jdbc.datasource.init.ResourceDatabasePopulator)17 Resource (org.springframework.core.io.Resource)7 ClassPathResource (org.springframework.core.io.ClassPathResource)6 DataSource (javax.sql.DataSource)3 Bean (org.springframework.context.annotation.Bean)3 DependsOn (org.springframework.context.annotation.DependsOn)3 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)3 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 Test (org.junit.Test)2 DataAccessException (org.springframework.dao.DataAccessException)2 PostConstruct (javax.annotation.PostConstruct)1 ByteArrayResource (org.springframework.core.io.ByteArrayResource)1 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)1 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)1 Transactional (org.springframework.transaction.annotation.Transactional)1 DefaultTransactionAttribute (org.springframework.transaction.interceptor.DefaultTransactionAttribute)1 TransactionAttribute (org.springframework.transaction.interceptor.TransactionAttribute)1 TransactionTemplate (org.springframework.transaction.support.TransactionTemplate)1