예제 #1
0
파일: App.java 프로젝트: kerryland/examples
      private EmbeddedDatabase populateDatabase(EmbeddedDatabase database) {
        // populate db
        final ResourceDatabasePopulator populator = populator();
        populator.setSqlScriptEncoding("UTF-8");
        populator.addScript(new ClassPathResource("sql/test-data.sql"));
        DatabasePopulatorUtils.execute(populator, database);

        return database;
      }
 @PostConstruct
 protected void initialize() throws Exception {
   String platform = DatabaseType.fromMetaData(this.dataSource).toString().toLowerCase();
   if ("hsql".equals(platform)) {
     platform = "hsqldb";
   }
   ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
   populator.addScript(
       this.resourceLoader.getResource(this.schemaLocation.replace("@@platform@@", platform)));
   populator.setContinueOnError(true);
   DatabasePopulatorUtils.execute(populator, this.dataSource);
 }
  @Bean
  public 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));

    DatabasePopulatorUtils.execute(populator, dataSource());
    return populator;
  }
예제 #4
0
 @Before
 public void setup() {
   ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
   populator.addScript(new ClassPathResource("jwp.sql"));
   DatabasePopulatorUtils.execute(populator, ConnectionManager.getDataSource());
 }