Java 类org.springframework.jdbc.datasource.init.DatabasePopulator 实例源码

项目:leopard    文件:DomainWhiteListConfigImpl.java   
protected void createTable() {
    StringBuilder sb = new StringBuilder();
    sb.append("CREATE TABLE  if not exists `leopard_domainwhitelist` (");
    sb.append("`domain` varchar(50) NOT NULL DEFAULT '',");
    sb.append("`username` varchar(50) NOT NULL DEFAULT '',");
    sb.append("`posttime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',");
    sb.append("`comment` varchar(255) NOT NULL DEFAULT '',");
    sb.append("PRIMARY KEY (`domain`)");
    sb.append(");");
    String sql = sb.toString();

    Resource scripts = new ByteArrayResource(sql.getBytes());
    DatabasePopulator populator = new ResourceDatabasePopulator(scripts);
    try {
        DatabasePopulatorUtils.execute(populator, jdbcTemplate.getDataSource());
    }
    catch (ScriptStatementFailedException e) {

    }
}
项目:Intro-to-Spring-Hadoop    文件:Application.java   
@Bean
DataSourceInitializer hiveInitializer(final DataSource dataSource) {
    final String ddl = "create external table if not exists tweetdata (value STRING) LOCATION '" + input + "'";
    final DataSourceInitializer dsi = new DataSourceInitializer();
    dsi.setDataSource(dataSource);
    dsi.setDatabasePopulator(new DatabasePopulator() {
        @Override
        public void populate(Connection conn) throws SQLException,
                ScriptException {
            Statement st = conn.createStatement();
            st.execute(ddl);
            st.close();
        }
    });
    return dsi;
}
项目:spring-hadoop-getting-started    文件:Application.java   
@Bean
DataSourceInitializer hiveInitializer(final DataSource dataSource) {
    final String ddl = "create external table if not exists tweetdata (value STRING) LOCATION '" + input + "'";
    final DataSourceInitializer dsi = new DataSourceInitializer();
    dsi.setDataSource(dataSource);
    dsi.setDatabasePopulator(new DatabasePopulator() {
        @Override
        public void populate(Connection conn) throws SQLException,
                ScriptException {
            Statement st = conn.createStatement();
            st.execute(ddl);
            st.close();
        }
    });
    return dsi;
}
项目:nixmash-blog    文件:H2Config.java   
@Bean
public DatabasePopulator databasePopulator(DataSource dataSource) {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.setContinueOnError(true);
    populator.setIgnoreFailedDrops(true);
    populator.addScripts(new ClassPathResource("/db/h2schema.sql"),
            new ClassPathResource("/db/h2data.sql"));
    try {
        populator.populate(dataSource.getConnection());
    } catch (SQLException ignored) {
    }
    return populator;
}
项目:spring-batch-admin    文件:DataSourceConfig.java   
private DatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.setIgnoreFailedDrops(true);
    populator.setContinueOnError(true);
    populator.addScript(dropScript);
    populator.addScript(schemaScript);
    return populator;
}
项目:dawn-marketplace-server    文件:DatabaseConfiguration.java   
private DatabasePopulator createDatabasePopulator() {
    ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
    databasePopulator.setContinueOnError(true);
    // populate the database with required tables
    databasePopulator.addScript(new ClassPathResource("schema.sql"));
    return databasePopulator;
}
项目:spring-data-repositories    文件:PersistenceConfiguration.java   
@Bean
public InitializingBean dataPopulator(final DataSource dataSource) {
    return () -> {
        final DatabasePopulator populator = new ResourceDatabasePopulator(new ClassPathResource("data.sql"));
        DatabasePopulatorUtils.execute(populator, dataSource);
    };
}
项目:spring-cloud-task-modules    文件:SqoopToolTaskApplicationTests.java   
@Bean
DatabasePopulator databasePopulator(DataSource dataSource) throws SQLException, InterruptedException {
    DatabasePopulator dbp = new ResourceDatabasePopulator(false, false, "UTF-8",
            new ClassPathResource("sqoop-test-schema-ddl.sql"),
            new ClassPathResource("sqoop-test-data.sql"));
    dbp.populate(DataSourceUtils.getConnection(dataSource));
    return dbp;
}
项目:spring-cloud-task-modules    文件:SqoopToolJobApplicationTests.java   
@Bean
DatabasePopulator databasePopulator(DataSource dataSource) throws SQLException, InterruptedException {
    DatabasePopulator dbp = new ResourceDatabasePopulator(false, false, "UTF-8",
            new ClassPathResource("sqoop-schema-ddl.sql"),
            new ClassPathResource("sqoop-root-data.sql"),
            new ClassPathResource("sqoop-sessions-data.sql"),
            new ClassPathResource("sqoop-test-schema-ddl.sql"),
            new ClassPathResource("sqoop-test-data.sql"));
    dbp.populate(DataSourceUtils.getConnection(dataSource));
    return dbp;
}
项目:spring-data-repositories    文件:PersistenceConfiguration.java   
@Bean
public InitializingBean dataPopulator(final DataSource dataSource) {
    return () -> {
        final DatabasePopulator populator = new ResourceDatabasePopulator(new ClassPathResource("data.sql"));
        DatabasePopulatorUtils.execute(populator, dataSource);
    };
}
项目:batchers    文件:TempConfigToInitDB.java   
private DatabasePopulator dataSourcePopulator() {
    ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
    databasePopulator.setScripts(
            new ClassPathResource(dropScript),
            new ClassPathResource(schemaScript)
    );
    return databasePopulator;
}
项目:batchers    文件:EmployeeJobTestConfig.java   
private DatabasePopulator dataSourcePopulator() {
    ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
    databasePopulator.setScripts(
            new ClassPathResource("org/springframework/batch/core/schema-drop-hsqldb.sql"),
            new ClassPathResource("org/springframework/batch/core/schema-hsqldb.sql")
    );
    return databasePopulator;
}
项目:Vaadin4Spring-MVP-Sample-SpringSecurity    文件:Application.java   
private DatabasePopulator databasePopulator() {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();      
    populator.addScript(new ClassPathResource("Account.sql", JdbcAccountRepository.class));
    populator.addScript(new ClassPathResource("data.sql", JdbcAccountRepository.class));
    populator.addScript(new ClassPathResource("rememberme.sql", JdbcAccountRepository.class));
    return populator;
}
项目:Vaadin4Spring-MVP-Sample-SpringSecuritySocial    文件:Application.java   
private DatabasePopulator databasePopulator() {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(new ClassPathResource("JdbcUsersConnectionRepository.sql", JdbcUsersConnectionRepository.class));
    populator.addScript(new ClassPathResource("Account.sql", JdbcAccountRepository.class));
    populator.addScript(new ClassPathResource("data.sql", JdbcAccountRepository.class));
    return populator;
}
项目:javaconfig-ftw    文件:MainConfig.java   
private DatabasePopulator databasePopulator() {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(new ClassPathResource("JdbcUsersConnectionRepository.sql", JdbcUsersConnectionRepository.class));
    populator.addScript(new ClassPathResource("Account.sql", JdbcAccountRepository.class));
    populator.addScript(new ClassPathResource("data.sql", JdbcAccountRepository.class));
    return populator;
}
项目:devops-cstack    文件:DatabaseConfiguration.java   
private DatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.setSqlScriptEncoding("utf-8");
    populator.addScript(dataScript);
    return populator;
}
项目:devops-cstack    文件:DatabaseConfigurationTest.java   
private DatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.setSqlScriptEncoding("utf-8");
    populator.addScript(dataScript);
    return populator;
}
项目:microservices-tcc-alfa    文件:AuthorizationServerConfiguration.java   
private DatabasePopulator databasePopulator() {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(schemaScript);
    return populator;
}
项目:nixmash-blog    文件:MySqlConfig.java   
@Bean
public DatabasePopulator databasePopulator() {
    return null;
}
项目:Building-Web-Apps-with-Spring-5-and-Angular    文件:AppConfig.java   
private DatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(schemaScript);
    populator.addScript(dataScript);
    return populator;
}
项目:Building-Web-Apps-with-Spring-5-and-Angular    文件:AppConfig.java   
private DatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(schemaScript);
    populator.addScript(dataScript);
    return populator;
}
项目:spring-boot    文件:OAuth2AuthorizationServerConfig.java   
private DatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(schemaScript);
    return populator;
}
项目:spring_boot    文件:PersistenceConfiguration.java   
private DatabasePopulator createDatabasePopulator() {
    ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
    databasePopulator.setContinueOnError(true);
    databasePopulator.addScript(new ClassPathResource("database/database.sql"));
    return databasePopulator;
}
项目:spring_boot    文件:PersistenceConfiguration.java   
private DatabasePopulator createDatabasePopulator() {
    ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
    databasePopulator.setContinueOnError(true);
    databasePopulator.addScript(new ClassPathResource("database/database.sql"));
    return databasePopulator;
}
项目:spring_boot    文件:PersistenceConfiguration.java   
private DatabasePopulator createDatabasePopulator() {
    ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
    databasePopulator.setContinueOnError(true);
    databasePopulator.addScript(new ClassPathResource("database/database.sql"));
    return databasePopulator;
}
项目:spring-boot-oauth2-server    文件:DataSourceConfig.java   
private DatabasePopulator databasePopulator() {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(schemaScript);
    return populator;
}
项目:spring-security-oauth    文件:OAuth2AuthorizationServerConfigInMemory.java   
private DatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(schemaScript);
    return populator;
}
项目:spring-security-oauth    文件:OAuth2AuthorizationServerConfig.java   
private DatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(schemaScript);
    populator.addScript(dataScript);
    return populator;
}
项目:shinyproxy    文件:SocialConfiguration.java   
private DatabasePopulator databasePopulator() {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(new ClassPathResource("JdbcUsersConnectionRepository.sql", JdbcUsersConnectionRepository.class));
    return populator;
}
项目:flowable-engine    文件:DatabaseInititializer.java   
private DatabasePopulator databasePopulator() {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(schemaScript);
    populator.addScript(dataScript);
    return populator;
}
项目:springJpaKata    文件:PopulatorConfig.java   
private DatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript((org.springframework.core.io.Resource) schemaScript);
    return populator;
}
项目:CCDA-Score-CARD    文件:PersistanceConfiguration.java   
private DatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(HSQL_SCHEMA_SCRIPT);
    return populator;
}
项目:demo-break-association    文件:JdbcTestCases.java   
private DatabasePopulator databasePopulator()
{
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(schemaScript);
    return populator;
}
项目:spring-time    文件:DatabaseConfig.java   
private DatabasePopulator databasePopulator() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    return populator;
}
项目:spring-time    文件:DatabaseConfig.java   
private DatabasePopulator databaseCleaner() {
    final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    return populator;
}
项目:maven-archetype-eventsourcing    文件:DataSourceInitializer.java   
private DatabasePopulator createDatabasePopulator() {
    ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
    databasePopulator.setContinueOnError(true);
    databasePopulator.addScript(new ClassPathResource("schema.sql"));
    return databasePopulator;
}
项目:maven-archetype-eventsourcing    文件:DataSourceInitializer.java   
private DatabasePopulator createDatabasePopulator() {
    ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
    databasePopulator.setContinueOnError(true);
    databasePopulator.addScript(new ClassPathResource("schema.sql"));
    return databasePopulator;
}
项目:lams    文件:EmbeddedDatabaseFactoryBean.java   
/**
 * Set a script execution to be run in the bean destruction callback,
 * cleaning up the database and leaving it in a known state for others.
 * @param databaseCleaner the database script executor to run on destroy
 * @see #setDatabasePopulator
 * @see org.springframework.jdbc.datasource.init.DataSourceInitializer#setDatabaseCleaner
 */
public void setDatabaseCleaner(DatabasePopulator databaseCleaner) {
    this.databaseCleaner = databaseCleaner;
}
项目:lams    文件:EmbeddedDatabaseFactory.java   
/**
 * Set the strategy that will be used to initialize or populate the embedded
 * database.
 * <p>Defaults to {@code null}.
 */
public void setDatabasePopulator(DatabasePopulator populator) {
    this.databasePopulator = populator;
}
项目:spring4-understanding    文件:EmbeddedDatabaseFactoryBean.java   
/**
 * Set a script execution to be run in the bean destruction callback,
 * cleaning up the database and leaving it in a known state for others.
 * @param databaseCleaner the database script executor to run on destroy
 * @see #setDatabasePopulator
 * @see org.springframework.jdbc.datasource.init.DataSourceInitializer#setDatabaseCleaner
 */
public void setDatabaseCleaner(DatabasePopulator databaseCleaner) {
    this.databaseCleaner = databaseCleaner;
}