Search in sources :

Example 61 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project Saturn by vipshop.

the class ServerCustomization method startEmbeddedDb.

public static void startEmbeddedDb() throws SQLException {
    EmbeddedDatabaseBuilder embeddedDatabaseBuilder = new EmbeddedDatabaseBuilder();
    embeddedDatabaseBuilder.setType(EmbeddedDatabaseType.H2).addScript("classpath:db/h2/global.sql").addScript("classpath:db/h2/schema.sql").addScript("classpath:db/h2/data.sql");
    String customSql = "classpath:db/h2/custom.sql";
    Resource resource = new DefaultResourceLoader().getResource(customSql);
    if (resource.exists()) {
        embeddedDatabaseBuilder.addScript(customSql);
    }
    embeddedDatabase = embeddedDatabaseBuilder.build();
    System.setProperty("db.profiles.active", "h2");
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) ImportResource(org.springframework.context.annotation.ImportResource) Resource(org.springframework.core.io.Resource) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader)

Example 62 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project SpringStepByStep by JavaProgrammerLB.

the class DatabaseConfig method dataSource.

@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).build();
    return db;
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) EmbeddedDatabase(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase) Bean(org.springframework.context.annotation.Bean)

Example 63 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project SpringStepByStep by JavaProgrammerLB.

the class DatabaseConfig method dataSource.

@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).addScript("sql/create-db.sql").addScript("sql/insert-data.sql").build();
    return db;
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) EmbeddedDatabase(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase) Bean(org.springframework.context.annotation.Bean)

Example 64 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project tutorials by eugenp.

the class PersistenceConfig method dataSource.

@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2).addScript("mySchema.sql").addScript("myData.sql").build();
    return db;
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) EmbeddedDatabase(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase) Bean(org.springframework.context.annotation.Bean)

Example 65 with EmbeddedDatabaseBuilder

use of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder in project tutorials by eugenp.

the class PersistenceConfig method dataSource.

@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).addScript("db/sql/data.sql").build();
    return db;
}
Also used : EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) EmbeddedDatabase(org.springframework.jdbc.datasource.embedded.EmbeddedDatabase) Bean(org.springframework.context.annotation.Bean)

Aggregations

EmbeddedDatabaseBuilder (org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder)67 Before (org.junit.Before)17 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)15 EmbeddedDatabase (org.springframework.jdbc.datasource.embedded.EmbeddedDatabase)15 JndiRegistry (org.apache.camel.impl.JndiRegistry)11 Bean (org.springframework.context.annotation.Bean)9 JdbcPropertyStore (org.ff4j.property.store.JdbcPropertyStore)5 FeatureStoreSpringJdbc (org.ff4j.springjdbc.store.FeatureStoreSpringJdbc)5 JdbcFeatureStore (org.ff4j.store.JdbcFeatureStore)5 JdbcQueryBuilder (org.ff4j.store.JdbcQueryBuilder)4 Test (org.junit.Test)4 PropertyStoreSpringJdbc (org.ff4j.springjdbc.store.PropertyStoreSpringJdbc)3 BeforeClass (org.junit.BeforeClass)3 Test (org.junit.jupiter.api.Test)3 PreparedStatement (java.sql.PreparedStatement)2 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)2 JdbcEventRepository (org.ff4j.audit.repository.JdbcEventRepository)2 Connection (java.sql.Connection)1 Map (java.util.Map)1 Properties (java.util.Properties)1