Java Code Examples for org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType

The following are top voted examples for showing how to use org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: FHIR-CQL-ODM-service   File: FhirTerminologyProviderServiceIT.java   Source Code and License 7 votes vote down vote up
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);	
}
 
Example 2
Project: FHIR-CQL-ODM-service   File: JpaFhirTerminologyProviderIT.java   Source Code and License 6 votes vote down vote up
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);	
}
 
Example 3
Project: FHIR-CQL-ODM-service   File: FhirServiceIT.java   Source Code and License 6 votes vote down vote up
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);	
}
 
Example 4
Project: spring-boot-multidatasource   File: DataSourceAutoConfiguration.java   Source Code and License 6 votes vote down vote up
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	ConditionMessage.Builder message = ConditionMessage
			.forCondition("EmbeddedDataSource");
	if (anyMatches(context, metadata, this.pooledCondition)) {
		return ConditionOutcome
				.noMatch(message.foundExactly("supported pooled data source"));
	}
	EmbeddedDatabaseType type = EmbeddedDatabaseConnection
			.get(context.getClassLoader()).getType();
	if (type == null) {
		return ConditionOutcome
				.noMatch(message.didNotFind("embedded database").atAll());
	}
	return ConditionOutcome.match(message.found("embedded database").items(type));
}
 
Example 5
Project: saluki   File: MybatisConfiguration.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 6
Project: spring-test-examples   File: Spring_2_IT_Configuration.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 7
Project: spring-test-examples   File: Spring_1_IT_Configuration.java   Source Code and License 6 votes vote down vote up
@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();
}
 
Example 8
Project: simple-openid-provider   File: JdbcRefreshTokenStoreIntegrationTests.java   Source Code and License 6 votes vote down vote up
@Bean
DataSource dataSource() {
	// @formatter:off
	return new EmbeddedDatabaseBuilder()
			.generateUniqueName(true)
			.setType(EmbeddedDatabaseType.H2)
			.addScript("schema-refresh-tokens.sql")
			.build();
	// @formatter:on
}
 
Example 9
Project: odotCore   File: TestCategoryDaoConfiguration.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 10
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
}
 
Example 11
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
}
 
Example 12
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 6 votes vote down vote up
/**
     * 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();
    }
 
Example 13
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
}
 
Example 14
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
}
 
Example 15
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 6 votes vote down vote up
/**
     * 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();
    }
 
Example 16
Project: iws   File: SpringConfig.java   Source Code and License 6 votes vote down vote up
private static DataSource hsqldbDataSource() {
    synchronized (LOCK) {
        if (dataSource == null) {
            dataSource = new EmbeddedDatabaseBuilder()
                    .setType(EmbeddedDatabaseType.HSQL)
                    .addScript("net/iaeste/iws/persistence/hsqldb/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/hsqldb/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;
    }
}
 
Example 17
Project: iws   File: SpringConfig.java   Source Code and License 6 votes vote down vote up
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;
    }
}
 
Example 18
Project: Camel   File: SqlTransactedRouteTest.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 19
Project: apparel   File: DatabaseConfig.java   Source Code and License 6 votes vote down vote up
@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();

}
 
Example 20
Project: pndao   File: MyBatisConfig.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 21
Project: spring-reactive-sample   File: DataSourceConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    return new EmbeddedDatabaseBuilder()
        .setType(EmbeddedDatabaseType.H2)
        .addScript("schema.sql")
        .build();
}
 
Example 22
Project: spring-reactive-sample   File: DataSourceConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    return new EmbeddedDatabaseBuilder()
        .setType(EmbeddedDatabaseType.H2)
        .addScript("schema.sql")
        .build();
}
 
Example 23
Project: spring-data-examples   File: CustomerConfig.java   Source Code and License 5 votes vote down vote up
@Bean
DataSource customerDataSource() {

	return new EmbeddedDatabaseBuilder().//
			setType(EmbeddedDatabaseType.HSQL).//
			setName("customers").//
			build();
}
 
Example 24
Project: spring-data-examples   File: OrderConfig.java   Source Code and License 5 votes vote down vote up
@Bean
DataSource orderDataSource() {

	return new EmbeddedDatabaseBuilder().//
			setType(EmbeddedDatabaseType.HSQL).//
			setName("orders").//
			build();
}
 
Example 25
Project: real-time-risk   File: H2DataSource.java   Source Code and License 5 votes vote down vote up
@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;

}
 
Example 26
Project: Your-Microservice   File: YourMicroserviceEnvironmentConfiguration.java   Source Code and License 5 votes vote down vote up
/**
 * DataSource
 * @return DataSource
 */
@Bean
@Primary
@ConfigurationProperties(prefix="datasource.idp")
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    return builder.setType(EmbeddedDatabaseType.H2).build();
}
 
Example 27
Project: spring-batch-support   File: DataSourceConfig.java   Source Code and License 5 votes vote down vote up
@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();
}
 
Example 28
Project: Using-Spring-Oauth2-to-secure-REST   File: Oauth2Application.java   Source Code and License 5 votes vote down vote up
@Bean @Qualifier("mainDataSource")
public DataSource dataSource(){
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder
			.setType(EmbeddedDatabaseType.H2)
			.build();
	return db;
}
 
Example 29
Project: Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token   File: DemoOauth2Application.java   Source Code and License 5 votes vote down vote up
@Bean @Qualifier("mainDataSource")
public DataSource dataSource(){
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
	EmbeddedDatabase db = builder
			.setType(EmbeddedDatabaseType.H2)
			.build();
	return db;
}
 
Example 30
Project: spring-configuration-support   File: SampleConfig.java   Source Code and License 5 votes vote down vote up
@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();
}
 
Example 31
Project: spring-i18n-support   File: WebappConfig.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 32
Project: simple-openid-provider   File: JdbcClientRepositoryIntegrationTests.java   Source Code and License 5 votes vote down vote up
@Bean
DataSource dataSource() {
	// @formatter:off
	return new EmbeddedDatabaseBuilder()
			.generateUniqueName(true)
			.setType(EmbeddedDatabaseType.H2)
			.addScript("schema-clients.sql")
			.build();
	// @formatter:on
}
 
Example 33
Project: odotCore   File: TestConfiguration.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 34
Project: odotCore   File: TestConfigurationEmptyDb.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 35
Project: camel-springboot   File: StoredProcTest.java   Source Code and License 5 votes vote down vote up
@Bean(value = "cityInfoDS")
@Primary
public DataSource createCityInfoDS(){
	return new EmbeddedDatabaseBuilder()
			.setType(EmbeddedDatabaseType.DERBY)
			.setName("CityInfoDatabase")
			.addScript("sql/GETZIPS.sql")
			.addScript("sql/StoredProcTest.sql")
			.build();
}
 
Example 36
Project: siga   File: SpringDBConfig.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 37
Project: holon-datastore-jpa   File: TestMultiTenant.java   Source Code and License 5 votes vote down vote up
@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();
	};
}
 
Example 38
Project: holon-datastore-jpa   File: TestMultiTenancy.java   Source Code and License 5 votes vote down vote up
@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();
}
 
Example 39
Project: spring-boot-starter-quartz   File: TestContextConfiguration7.java   Source Code and License 5 votes vote down vote up
@Bean("dataSource")
public DataSource dataSource() {
	
	return new EmbeddedDatabaseBuilder().generateUniqueName(true)
            .setType(EmbeddedDatabaseType.H2)
            .setScriptEncoding("UTF-8")
            .ignoreFailedDrops(true).build();
}
 
Example 40
Project: spring-boot-starter-quartz   File: TestContextConfiguration7.java   Source Code and License 5 votes vote down vote up
@Bean("otherDataSource")
@Primary
public DataSource otherDataSource() {
	
	return new EmbeddedDatabaseBuilder().generateUniqueName(true)
            .setType(EmbeddedDatabaseType.H2)
            .setScriptEncoding("UTF-8")
            .ignoreFailedDrops(true).build();
}
 
Example 41
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 5 votes vote down vote up
/**
 * Custom H2 implementation for our {@link EmbeddedDatabase}
 * @return
 */
@Bean
public DataSource dataSource() {
    return new EmbeddedDatabaseBuilder()
            .setName("dataSource")
            .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();
}
 
Example 42
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 5 votes vote down vote up
/**
 * Embedded H2 database
 * Connect to running database with the following details:
 *
 * URL: jdbc:h2:mem:dataSource
 * Driver Class: org.h2.Driver
 * Username: sa
 * Password: [blank]
 *
 * @return
 */
@Bean
public DataSource dataSource() {
    final EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    database = builder.setType(EmbeddedDatabaseType.H2)
            .setName("dataSource")
            .ignoreFailedDrops(true)
            .continueOnError(false)
            .addScript("classpath:database/h2/calendar-schema.sql")
            .addScript("classpath:database/h2/calendar-data.sql")
            .build();
    return database;
}
 
Example 43
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 5 votes vote down vote up
/**
 * Embedded H2 database
 * Connect to running database with the following details:
 *
 * URL: jdbc:h2:mem:dataSource
 * Driver Class: org.h2.Driver
 * Username: sa
 * Password: [blank]
 *
 * @return
 */
@Bean
public DataSource dataSource() {
    final EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    database = builder.setType(EmbeddedDatabaseType.H2)
            .setName("dataSource")
            .ignoreFailedDrops(true)
            .continueOnError(false)
            .addScript("classpath:database/h2/calendar-schema.sql")
            .addScript("classpath:database/h2/calendar-data.sql")
            .build();
    return database;
}
 
Example 44
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 5 votes vote down vote up
/**
 * Embedded H2 database
 * Connect to running database with the following details:
 *
 * URL: jdbc:h2:mem:dataSource
 * Driver Class: org.h2.Driver
 * Username: sa
 * Password: [blank]
 *
 * @return
 */
@Bean
public DataSource dataSource() {
    final EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    database = builder.setType(EmbeddedDatabaseType.H2)
            .setName("dataSource")
            .ignoreFailedDrops(true)
            .continueOnError(false)
            .addScript("classpath:database/h2/calendar-schema.sql")
            .addScript("classpath:database/h2/calendar-data.sql")
            .build();
    return database;
}
 
Example 45
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 5 votes vote down vote up
/**
 * Embedded H2 database
 * Connect to running database with the following details:
 *
 * URL: jdbc:h2:mem:dataSource
 * Driver Class: org.h2.Driver
 * Username: sa
 * Password: [blank]
 *
 * @return
 */
@Bean
public DataSource dataSource() {
    final EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    database = builder.setType(EmbeddedDatabaseType.H2)
            .setName("dataSource")
            .ignoreFailedDrops(true)
            .continueOnError(false)
            .addScript("classpath:database/h2/calendar-schema.sql")
            .addScript("classpath:database/h2/calendar-data.sql")
            .build();
    return database;
}
 
Example 46
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 5 votes vote down vote up
/**
 * Embedded H2 database
 * Connect to running database with the following details:
 *
 * URL: jdbc:h2:mem:dataSource
 * Driver Class: org.h2.Driver
 * Username: sa
 * Password: [blank]
 *
 * @return
 */
@Bean
public DataSource dataSource() {
    final EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    database = builder.setType(EmbeddedDatabaseType.H2)
            .setName("dataSource")
            .ignoreFailedDrops(true)
            .continueOnError(false)
            .addScript("classpath:database/h2/calendar-schema.sql")
            .addScript("classpath:database/h2/calendar-data.sql")
            .build();
    return database;
}
 
Example 47
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 5 votes vote down vote up
/**
 * Embedded H2 database
 * Connect to running database with the following details:
 *
 * URL: jdbc:h2:mem:dataSource
 * Driver Class: org.h2.Driver
 * Username: sa
 * Password: [blank]
 *
 * @return
 */
@Bean
public DataSource dataSource() {
    final EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    database = builder.setType(EmbeddedDatabaseType.H2)
            .setName("dataSource")
            .ignoreFailedDrops(true)
            .continueOnError(false)
            .addScript("classpath:database/h2/calendar-schema.sql")
            .addScript("classpath:database/h2/calendar-data.sql")
            .build();
    return database;
}
 
Example 48
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 5 votes vote down vote up
/**
 * Embedded H2 database
 * Connect to running database with the following details:
 *
 * URL: jdbc:h2:mem:dataSource
 * Driver Class: org.h2.Driver
 * Username: sa
 * Password: [blank]
 *
 * @return
 */
@Bean
public DataSource dataSource() {
    final EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    database = builder.setType(EmbeddedDatabaseType.H2)
            .setName("dataSource")
            .ignoreFailedDrops(true)
            .continueOnError(false)
            .addScript("classpath:database/h2/calendar-schema.sql")
            .addScript("classpath:database/h2/calendar-data.sql")
            .build();
    return database;
}
 
Example 49
Project: Spring-Security-Third-Edition   File: DataSourceConfig.java   Source Code and License 5 votes vote down vote up
/**
 * Embedded H2 database
 * Connect to running database with the following details:
 *
 * URL: jdbc:h2:mem:dataSource
 * Driver Class: org.h2.Driver
 * Username: sa
 * Password: [blank]
 *
 * @return
 */
@Bean
public DataSource dataSource() {
    final EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    database = builder.setType(EmbeddedDatabaseType.H2)
            .setName("dataSource")
            .ignoreFailedDrops(true)
            .continueOnError(false)
            .addScript("classpath:database/h2/calendar-schema.sql")
            .addScript("classpath:database/h2/calendar-data.sql")
            .build();
    return database;
}
 
Example 50
Project: introducing-spring-framework   File: WebConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
	return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL)
			.addScript("classpath:/META-INF/data/schema.sql")
			.addScript("classpath:/META-INF/data/data.sql")
			.build();
}
 
Example 51
Project: introducing-spring-framework   File: JDBCConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).
        addScript("META-INF/data/schema.sql").
        addScript("META-INF/data/data.sql").build();
    return db;
}
 
Example 52
Project: introducing-spring-framework   File: MyDocumentsApp.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).
        addScript("META-INF/data/schema.sql").
        addScript("META-INF/data/data.sql").build();
    return db;
}
 
Example 53
Project: introducing-spring-framework   File: MyDocumentsWebApp.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).
        addScript("META-INF/data/schema.sql").
        addScript("META-INF/data/data.sql").build();
    return db;
}
 
Example 54
Project: java-a-to-z   File: UserStorageTest.java   Source Code and License 5 votes vote down vote up
@Before
public void setUp() {
    embeddedDatabase = new EmbeddedDatabaseBuilder()
            .addDefaultScripts()
            .setType(EmbeddedDatabaseType.H2)
            .build();

    jdbcTemplate = new JdbcTemplate(embeddedDatabase);
}
 
Example 55
Project: pndaox   File: MyBatisConfig.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 56
Project: spring-data-mybatis   File: TestConfig.java   Source Code and License 5 votes vote down vote up
@Bean
public DataSource routingDataSource() throws SQLException {
    EmbeddedDatabase embeddedDatabase = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).addScript("classpath:/test-init.sql").build();

    ReplicationRoutingDataSource proxy = new ReplicationRoutingDataSource(embeddedDatabase, null);
    proxy.addSlave(embeddedDatabase);
    proxy.addSlave(embeddedDatabase);
    proxy.addSlave(embeddedDatabase);
    return proxy;
}
 
Example 57
Project: Camel   File: SqlProducerNoopTest.java   Source Code and License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    db = new EmbeddedDatabaseBuilder()
            .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();

    super.setUp();
}
 
Example 58
Project: Camel   File: SqlConsumerDeleteBatchCompleteTest.java   Source Code and License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    db = new EmbeddedDatabaseBuilder()
        .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();

    jdbcTemplate = new JdbcTemplate(db);

    super.setUp();
}
 
Example 59
Project: Camel   File: SqlEndpointTest.java   Source Code and License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    db = new EmbeddedDatabaseBuilder()
        .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
    
    super.setUp();
}
 
Example 60
Project: Camel   File: SqlProducerOutputHeaderWithQueryTest.java   Source Code and License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    db = new EmbeddedDatabaseBuilder()
            .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();

    super.setUp();
}