Java Code Examples for org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder#build()

The following examples show how to use org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JpaConfig.java    From Project with Apache License 2.0 5 votes vote down vote up
@Bean
public DataSource dataSource() {
  EmbeddedDatabaseBuilder edb = new EmbeddedDatabaseBuilder();
  edb.setType(EmbeddedDatabaseType.H2);
  edb.addScript("spittr/db/jpa/schema.sql");
  edb.addScript("spittr/db/jpa/test-data.sql");
  EmbeddedDatabase embeddedDatabase = edb.build();
  return embeddedDatabase;
}
 
Example 2
Source File: WithRoutingDataSourceConfig.java    From replication-datasource with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "shutdown")
public DataSource readDataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
            .setName("routingReadDb")
            .setType(EmbeddedDatabaseType.H2)
            .setScriptEncoding("UTF-8")
            .addScript("classpath:/readdb.sql");
    return builder.build();
}
 
Example 3
Source File: WithRoutingDataSourceConfig.java    From replication-datasource with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "shutdown")
public DataSource writeDataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
            .setName("routingWriteDb")
            .setType(EmbeddedDatabaseType.H2)
            .setScriptEncoding("UTF-8")
            .addScript("classpath:/writedb.sql");
    return builder.build();
}
 
Example 4
Source File: WithLazyReplicationConnectionDataSourceProxyConfig.java    From replication-datasource with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "shutdown")
public DataSource readDataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
            .setName("lazyReadDb")
            .setType(EmbeddedDatabaseType.H2)
            .setScriptEncoding("UTF-8")
            .addScript("classpath:/readdb.sql");
    return builder.build();
}
 
Example 5
Source File: WithLazyReplicationConnectionDataSourceProxyConfig.java    From replication-datasource with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "shutdown")
public DataSource writeDataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
            .setName("lazyWriteDb")
            .setType(EmbeddedDatabaseType.H2)
            .setScriptEncoding("UTF-8")
            .addScript("classpath:/writedb.sql");
    return builder.build();
}
 
Example 6
Source File: TaskBatchExecutionListenerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Bean
@Primary
public DataSource myDataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
			.setType(EmbeddedDatabaseType.H2).setName("myDataSource");
	return builder.build();
}
 
Example 7
Source File: WithRoutingDataSourceConfig.java    From replication-datasource with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "shutdown")
public DataSource readDataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
            .setName("routingReadDb")
            .setType(EmbeddedDatabaseType.H2)
            .setScriptEncoding("UTF-8")
            .addScript("classpath:/readdb.sql");
    return builder.build();
}
 
Example 8
Source File: WithRoutingDataSourceConfig.java    From replication-datasource with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "shutdown")
public DataSource writeDataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
            .setName("routingWriteDb")
            .setType(EmbeddedDatabaseType.H2)
            .setScriptEncoding("UTF-8")
            .addScript("classpath:/writedb.sql");
    return builder.build();
}
 
Example 9
Source File: WithLazyReplicationConnectionDataSourceProxyConfig.java    From replication-datasource with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "shutdown")
public DataSource readDataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
            .setName("lazyReadDb")
            .setType(EmbeddedDatabaseType.H2)
            .setScriptEncoding("UTF-8")
            .addScript("classpath:/readdb.sql");
    return builder.build();
}
 
Example 10
Source File: WithLazyReplicationConnectionDataSourceProxyConfig.java    From replication-datasource with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "shutdown")
public DataSource writeDataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
            .setName("lazyWriteDb")
            .setType(EmbeddedDatabaseType.H2)
            .setScriptEncoding("UTF-8")
            .addScript("classpath:/writedb.sql");
    return builder.build();
}
 
Example 11
Source File: InfrastructureConfig.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 5 votes vote down vote up
@Bean
public DataSource dataSource(){
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2);//in-memory
	builder.addScript("schema.sql");
	builder.addScript("data.sql");
	return builder.build();
}
 
Example 12
Source File: InfrastructureConfig.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 5 votes vote down vote up
@Bean
public DataSource dataSource(){
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2);//in-memory
	builder.addScript("schema.sql");
	builder.addScript("data.sql");
	return builder.build();
}
 
Example 13
Source File: InfrastructureConfig.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 5 votes vote down vote up
@Bean
public DataSource dataSource(){
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2);//in-memory
	builder.addScript("schema.sql");
	builder.addScript("data.sql");
	return builder.build();
}
 
Example 14
Source File: DataConfig.java    From Project with Apache License 2.0 5 votes vote down vote up
@Bean
public DataSource dataSource() {
  EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
  builder.setType(EmbeddedDatabaseType.H2);
  builder.addScript("classpath:spittr/db/jdbc/schema.sql");
  builder.addScript("classpath:spittr/db/jdbc/test-data.sql");
  return builder.build();
}
 
Example 15
Source File: JpaConfig.java    From Project with Apache License 2.0 5 votes vote down vote up
@Bean
public DataSource dataSource() {
  EmbeddedDatabaseBuilder edb = new EmbeddedDatabaseBuilder();
  edb.setType(EmbeddedDatabaseType.H2);
  edb.addScript("spittr/db/jpa/schema.sql");
  edb.addScript("spittr/db/jpa/test-data.sql");
  EmbeddedDatabase embeddedDatabase = edb.build();
  return embeddedDatabase;
}
 
Example 16
Source File: RepositoryTestConfig.java    From Project with Apache License 2.0 5 votes vote down vote up
@Bean
public DataSource dataSource() {
  EmbeddedDatabaseBuilder edb = new EmbeddedDatabaseBuilder();
  edb.setType(EmbeddedDatabaseType.H2);
  edb.addScript("spittr/db/hibernate4/schema.sql");
  edb.addScript("spittr/db/hibernate4/test-data.sql");
  EmbeddedDatabase embeddedDatabase = edb.build();
  return embeddedDatabase;
}
 
Example 17
Source File: TaskBatchExecutionListenerTests.java    From spring-cloud-task with Apache License 2.0 4 votes vote down vote up
@Bean
public DataSource incorrectDataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
			.setType(EmbeddedDatabaseType.H2).setName("incorrectDataSource");
	return builder.build();
}
 
Example 18
Source File: TaskExecutionDaoFactoryBeanTests.java    From spring-cloud-task with Apache License 2.0 4 votes vote down vote up
@Bean
public DataSource dataSource() {
	EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()
			.setType(EmbeddedDatabaseType.H2);
	return builder.build();
}
 
Example 19
Source File: TestConfiguration.java    From nestedj with MIT License 4 votes vote down vote up
@Bean
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).setName(UUID.randomUUID().toString());
    return builder.build();
}