private static void setupEmbeddedDatabase() throws NamingException{ SimpleNamingContextBuilder builder = SimpleNamingContextBuilder .emptyActivatedContextBuilder(); EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase db = dbBuilder .setType(EmbeddedDatabaseType.DERBY) .setName("usciitg") .setScriptEncoding("UTF-8") .ignoreFailedDrops(true) .addScript("org/partners/usciitg_prep/terminology/jpa/create-db.sql") .addScript("org/partners/usciitg_prep/terminology/jpa/insert-data.sql") .build(); builder.bind(System.getProperty("usciitg.datasource"), db); }
private static void setupEmbeddedDatabase() throws NamingException{ SimpleNamingContextBuilder builder = SimpleNamingContextBuilder .emptyActivatedContextBuilder(); EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase db = dbBuilder .setType(EmbeddedDatabaseType.DERBY) .setName("usciitg") .setScriptEncoding("UTF-8") .ignoreFailedDrops(true) .addScript("org/partners/usciitg_prep/terminology/jpa/create-db.sql") .addScript("org/partners/usciitg_prep/fhir/cql/insert-data.sql") .build(); builder.bind(System.getProperty("usciitg.datasource"), db); }
private static void setupEmbeddedDatabase() throws NamingException{ SimpleNamingContextBuilder builder = SimpleNamingContextBuilder .emptyActivatedContextBuilder(); EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase db = dbBuilder .setType(EmbeddedDatabaseType.DERBY) .setName("usciitg") .setScriptEncoding("UTF-8") .ignoreFailedDrops(true) .addScript("org/partners/usciitg_prep/terminology/jpa/create-db.sql") .addScript("org/partners/usciitg_prep/fhir/cql/insert-data.sql") .addScript("org/partners/usciitg_prep/fhir/create-db.sql") .addScript("org/partners/usciitg_prep/fhir/insert-data.sql") .build(); builder.bind(System.getProperty("usciitg.datasource"), db); }
@Bean @ConditionalOnMissingBean(EmbeddedDatabase.class) public EmbeddedDatabase dataSource() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2) // .setName("grpcmonitor")// .addScript("mapper/create-db.sql")// .build(); return db; }
@Bean public DataSource dataSource() { EmbeddedDatabase db = new EmbeddedDatabaseBuilder() .generateUniqueName(true) .setType(EmbeddedDatabaseType.H2) .setScriptEncoding("UTF-8") .ignoreFailedDrops(true) .addScript("classpath:me/chanjar/domain/foo-ddl.sql") .build(); return db; }
@Bean(destroyMethod = "shutdown") public DataSource dataSource() { return new EmbeddedDatabaseBuilder() .generateUniqueName(true) .setType(EmbeddedDatabaseType.H2) .setScriptEncoding("UTF-8") .ignoreFailedDrops(true) .addScript("classpath:me/chanjar/domain/foo-ddl.sql") .build(); }
@Bean DataSource dataSource() { // @formatter:off return new EmbeddedDatabaseBuilder() .generateUniqueName(true) .setType(EmbeddedDatabaseType.H2) .addScript("schema-clients.sql") .build(); // @formatter:on }
@Bean DataSource dataSource() { // @formatter:off return new EmbeddedDatabaseBuilder() .generateUniqueName(true) .setType(EmbeddedDatabaseType.H2) .addScript("schema-refresh-tokens.sql") .build(); // @formatter:on }
@Override @Bean(name = "dataSource") public DataSource getDataSource() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase embeddedDb = builder .setType(EmbeddedDatabaseType.DERBY) .ignoreFailedDrops(true) .addScript("sql/create_tables.sql") .addScript("sql/insert_just_category_data.sql") .build(); return embeddedDb; }
/** * Custom H2 implementation for our {@link EmbeddedDatabase} * @return */ @Bean public DataSource dataSource() { // no need shutdown, EmbeddedDatabaseFactoryBean will take care of this return new EmbeddedDatabaseBuilder() //Starting embedded database: url='jdbc:h2:mem:dataSource;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false', username='sa' .setName("dataSource") // Lets not get upset as we are only debugging ;-) .ignoreFailedDrops(true) .continueOnError(true) // DB Details: .setType(EmbeddedDatabaseType.H2) .addScript("/database/h2/calendar-schema.sql") .addScript("/database/h2/calendar-data.sql") // Authority tables .addScript("/database/h2/calendar-authorities.sql") .addScript("/database/h2/calendar-sha256.sql") .build(); }
/** * Custom H2 implementation for our {@link EmbeddedDatabase} * @return */ @Bean public DataSource dataSource() { // no need shutdown, EmbeddedDatabaseFactoryBean will take care of this return new EmbeddedDatabaseBuilder() //Starting embedded database: url='jdbc:h2:mem:dataSource;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false', username='sa' .setName("dataSource") // Lets not get upset as we are only debugging ;-) .ignoreFailedDrops(true) .continueOnError(true) // DB Details: .setType(EmbeddedDatabaseType.H2) .addScript("/database/h2/calendar-schema.sql") .addScript("/database/h2/calendar-data.sql") .addScript("/database/h2/security-schema.sql") .addScript("/database/h2/security-users.sql") .addScript("/database/h2/security-user-authorities.sql") .build(); }
/** * Custom H2 implementation for our {@link EmbeddedDatabase} * @return */ @Bean public DataSource dataSource() { // no need shutdown, EmbeddedDatabaseFactoryBean will take care of this return new EmbeddedDatabaseBuilder() //Starting embedded database: url='jdbc:h2:mem:dataSource;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false', username='sa' .setName("dataSource") // Lets not get upset as we are only debugging ;-) .ignoreFailedDrops(true) .continueOnError(true) // DB Details: .setType(EmbeddedDatabaseType.H2) .addScript("/database/h2/calendar-schema.sql") .addScript("/database/h2/calendar-data.sql") // Authority tables .addScript("/database/h2/calendar-authorities.sql") // .addScript("/database/h2/calendar-saltedsha256.sql") .addScript("/database/h2/calendar-bcrypt.sql") .build(); }
/** * Custom H2 implementation for our {@link EmbeddedDatabase} * @return */ @Bean public DataSource dataSource() { // no need shutdown, EmbeddedDatabaseFactoryBean will take care of this return new EmbeddedDatabaseBuilder() //Starting embedded database: url='jdbc:h2:mem:dataSource;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false', username='sa' .setName("dataSource") // Lets not get upset as we are only debugging ;-) .ignoreFailedDrops(true) .continueOnError(true) // DB Details: .setType(EmbeddedDatabaseType.H2) .addScript("/database/h2/calendar-schema.sql") .addScript("/database/h2/calendar-data.sql") // Security SQL .addScript("/database/h2/security-schema.sql") .addScript("/database/h2/security-users.sql") .addScript("/database/h2/security-groups-schema.sql") .addScript("/database/h2/security-groups-mappings.sql") .build(); }
/** * Custom H2 implementation for our {@link EmbeddedDatabase} * @return */ @Bean public DataSource dataSource() { // no need shutdown, EmbeddedDatabaseFactoryBean will take care of this return new EmbeddedDatabaseBuilder() //Starting embedded database: url='jdbc:h2:mem:dataSource;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false', username='sa' .setName("dataSource") // Lets not get upset as we are only debugging ;-) .ignoreFailedDrops(true) .continueOnError(true) // DB Details: .setType(EmbeddedDatabaseType.H2) .addScript("/database/h2/calendar-schema.sql") .addScript("/database/h2/calendar-data.sql") // Authority tables .addScript("/database/h2/calendar-authorities.sql") .build(); }
private static DataSource h2DataSource() { synchronized (LOCK) { if (dataSource == null) { dataSource = new EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("net/iaeste/iws/persistence/h2/10-base-tables.sql") .addScript("net/iaeste/iws/persistence/15-base-views.sql") .addScript("net/iaeste/iws/persistence/19-base-data.sql") .addScript("net/iaeste/iws/persistence/h2/30-exchange-tables.sql") .addScript("net/iaeste/iws/persistence/35-exchange-views.sql") .addScript("net/iaeste/iws/persistence/90-initial-test-data.sql") .build(); } return dataSource; } }
@Bean public DataSource dataSourceProd() { String databaseUrl = env.getProperty("database.url"); String databaseUsername = env.getProperty("database.username"); String databasePassword = env.getProperty("database.password"); if(databaseUrl == null || databaseUsername == null || databasePassword == null) { logger.log(Level.ALL, "Using local H2 database"); return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build(); } logger.log(Level.ALL, "Using database " + databaseUrl); return DataSourceBuilder.create() .url(databaseUrl) .username(databaseUsername) .password(databasePassword) .build(); }
@Override protected JndiRegistry createRegistry() throws Exception { JndiRegistry reg = super.createRegistry(); db = new EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.DERBY).build(); reg.bind("testdb", db); DataSourceTransactionManager txMgr = new DataSourceTransactionManager(); txMgr.setDataSource(db); reg.bind("txManager", txMgr); SpringTransactionPolicy txPolicy = new SpringTransactionPolicy(); txPolicy.setTransactionManager(txMgr); txPolicy.setPropagationBehaviorName("PROPAGATION_REQUIRED"); reg.bind("required", txPolicy); return reg; }
@Bean public DataSource dataSource() { //TODO:just for test, replace by your own datasource EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase db = builder .setType(EmbeddedDatabaseType.H2) //.H2 or .DERBY .addScript("db/sql/create-db.sql") .addScript("db/sql/insert-data.sql") .build(); return db; }
@Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .addScript("schema.sql") .build(); }
@Bean DataSource customerDataSource() { return new EmbeddedDatabaseBuilder().// setType(EmbeddedDatabaseType.HSQL).// setName("customers").// build(); }
@Bean DataSource orderDataSource() { return new EmbeddedDatabaseBuilder().// setType(EmbeddedDatabaseType.HSQL).// setName("orders").// build(); }
@Bean public DataSource dataSource() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2) .addScript("db/create-db.sql") .addScript("db/insert-data.sql").build(); return db; }
/** * DataSource * @return DataSource */ @Bean @Primary @ConfigurationProperties(prefix="datasource.idp") public DataSource dataSource() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); return builder.setType(EmbeddedDatabaseType.H2).build(); }
@Bean public DataSource dataSource() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); return builder.setType(EmbeddedDatabaseType.H2) .setName("namicsBatch") .addScript("classpath:org/springframework/batch/core/schema-h2.sql") .build(); }
@Bean @Qualifier("mainDataSource") public DataSource dataSource(){ EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase db = builder .setType(EmbeddedDatabaseType.H2) .build(); return db; }
@Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.H2) .generateUniqueName(true) .ignoreFailedDrops(true) .setScriptEncoding("UTF-8") .addScripts("classpath:/db/schema.sql", "classpath:/db/data.sql") .build(); }
@Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder() .continueOnError(true) .addScripts("classpath:/META-INF/db/schema.sql", "classpath:/META-INF/db/test-data.sql") .build(); }
@Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder() .continueOnError(true) .addScripts("classpath:/com/namics/oss/spring/support/configuration/default-schema.sql", "classpath:/META-INF/db/namics-configuration-default-data.sql") .build(); }
@Bean public DataSource dataSource() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2) .addScript("/jdbc/schema.sql") .addScript("/jdbc/data.sql") .build(); return db; }
@Override @Bean(name = "dataSource") public DataSource getDataSource() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase embeddedDb = builder .setType(EmbeddedDatabaseType.DERBY) .ignoreFailedDrops(true) // .addScript("sql/drop_tables.sql") .addScript("sql/create_tables.sql") .addScript("sql/insert_data.sql") .build(); return embeddedDb; }
@Override @Bean(name = "dataSource") public DataSource getDataSource() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase embeddedDb = builder .setType(EmbeddedDatabaseType.DERBY) .ignoreFailedDrops(true) .addScript("sql/create_tables.sql") // NO DATA .build(); return embeddedDb; }
@Bean(value = "cityInfoDS") @Primary public DataSource createCityInfoDS(){ return new EmbeddedDatabaseBuilder() .setType(EmbeddedDatabaseType.DERBY) .setName("CityInfoDatabase") .addScript("sql/GETZIPS.sql") .addScript("sql/StoredProcTest.sql") .build(); }
@Bean public DataSource getDataSource() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); EmbeddedDatabase db = builder.setName("testdb").setType(EmbeddedDatabaseType.HSQL) .addScript("db/sql/create-db.sql").addScript("db/sql/insert-data.sql").build(); return db; }
@Bean public TenantDataSourceProvider tenantDataSourceProvider() { return tenantId -> { if (tenantId == null) { // for hibernate startup return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).setName("startup") .addScript("scripts/test-db-schema.sql").build(); } return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).setName(tenantId) .addScript("scripts/test-db-schema.sql").addScript("scripts/test-db-data-" + tenantId + ".sql") .build(); }; }
@Bean(destroyMethod = "close") public MultiTenantDataSource dataSource() { return MultiTenantDataSource.builder().resolver(() -> Optional.ofNullable(TENANT.get())) .provider(tenantId -> { if (tenantId == null) { // for hibernate startup return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).setName("startup") .addScript("test-db-schema.sql").build(); } return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).setName(tenantId) .addScript("test-db-schema.sql").addScript("test-db-data-" + tenantId + ".sql").build(); }).build(); }