Spring Framework ResourceDatabasePopulator - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ResourceDatabasePopulator class.

This code example shows how to use the following methods:addScript, populate, setContinueOnError, setIgnoreFailedDrops
This code example shows how to use the following methods:addScript, populate
    } 
 
    @Bean 
    @DependsOn("entityManagerFactory") 
    public ResourceDatabasePopulator initDatabase(DataSource dataSource) throws Exception { 
        ResourceDatabasePopulator populator = new ResourceDatabasePopulator(); 
        populator.addScript(new ClassPathResource("data.sql")); 
        populator.populate(dataSource.getConnection()); 
        return populator; 
    } 
 
    @Bean 
    public PlatformTransactionManager transactionManager() { 
        JpaTransactionManager txManager = new JpaTransactionManager(); 
        txManager.setEntityManagerFactory(entityManagerFactory().getObject()); 
        return txManager; 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:addScript, populate
    } 
 
    @Bean 
    @DependsOn("entityManagerFactory") 
    public ResourceDatabasePopulator initDatabase(DataSource dataSource) throws Exception { 
        ResourceDatabasePopulator populator = new ResourceDatabasePopulator(); 
        populator.addScript(new ClassPathResource("data.sql")); 
        populator.populate(dataSource.getConnection()); 
        return populator; 
    } 
 
    @Bean 
    public PlatformTransactionManager transactionManager() { 
        JpaTransactionManager txManager = new JpaTransactionManager(); 
        txManager.setEntityManagerFactory(entityManagerFactory().getObject()); 
        return txManager; 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:addScript
This code example shows how to use the following methods:addScript, populate, setContinueOnError, setIgnoreFailedDrops
This code example shows how to use the following methods:addScript, populate
This code example shows how to use the following methods:addScript, populate, setContinueOnError, setIgnoreFailedDrops
This code example shows how to use the following methods:addScript, populate
    private static Environment environment = TestProfileEnvironment.getEnvironment();
 
    private static String platform = environment.acceptsProfiles("postgresql") ? "postgresql" : "hsqldb";
 
    public static void runScript(DataSource dataSource, String stem) throws Exception {
        ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
        String packageName = ClassUtils.getPackageName(TestUtils.class).replace(".", "/");
        populator.addScript(new ClassPathResource(packageName.substring(0, packageName.lastIndexOf("/")) + "/" + stem
                        + "-" + platform + ".sql"));
        Connection connection = dataSource.getConnection();
        try { 
            populator.populate(connection);
        } catch (ScriptStatementFailedException e) {
            // ignore 
        } finally { 
            DataSourceUtils.releaseConnection(connection, dataSource);
        } 
    } 
 
    public static void createSchema(DataSource dataSource) throws Exception {
6
CodeRank
This code example shows how to use the following methods:addScript, populate, setContinueOnError, setIgnoreFailedDrops
This code example shows how to use the following methods:addScript, populate
See Code Examples for Spring Framework ResourceDatabasePopulator Methods: