All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.marschall.threeten.jpa.test.configuration.DerbyConfiguration Maven / Gradle / Ivy

package com.github.marschall.threeten.jpa.test.configuration;

import static org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType.DERBY;

import java.util.concurrent.atomic.AtomicInteger;

import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;

@Configuration
public class DerbyConfiguration {
  
  private static final AtomicInteger COUNT = new AtomicInteger();
  
  @Bean
  public DataSource dataSource() {
    return new EmbeddedDatabaseBuilder()
         // the spring test context framework keeps application contexts
         // and thus databases around for the entire VM lifetime
         // so be have to create a unique name here to avoid sharing
         // between application contexts
        .setName("Derby-" + COUNT.incrementAndGet())
        .setType(DERBY)
        .addScript("derby-schema.sql")
        .addScript("derby-data.sql")
        .build();
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy