@Bean(name = "dataSource")
 @Profile("embedded")
 // -Dspring.profiles.active=embedded
 public DataSource inMemoryDataSource() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   return builder.setType(EmbeddedDatabaseType.HSQL).addScript("/schema-hsql.sql").build();
 }
 @BeforeClass
 public static void init() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   database = builder.build();
   flyway = new Flyway();
   flyway.setInitVersion("1.5.2");
   flyway.setLocations("classpath:/org/cloudfoundry/identity/uaa/db/hsqldb/");
   flyway.setDataSource(database);
   flyway.migrate();
 }
  @Bean
  public DataSource dataSource(Environment env) throws Exception {

    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db =
        builder
            .setType(EmbeddedDatabaseType.H2)
            .addScript("db_create.sql")
            .addScript("db_data_init.sql")
            .build();
    return db;
  }
  @Bean
  public DataSource dataSource() {

    EmbeddedDatabaseBuilder dbBuilder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase database =
        dbBuilder
            .setType(EmbeddedDatabaseType.HSQL)
            .addScript(DDL_SCRIPT)
            .addScript(DML_SCRIPT)
            .build();

    return database;
  }
 /**
  * Spring provided H2 Embedded Database. Read the dbscript and initiates the Database with the
  * name H2-Test-DB.
  *
  * @return DataSource
  */
 @Bean(name = "dataSource")
 public DataSource dataSource() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   builder.setName("H2-Test-DB");
   EmbeddedDatabase db =
       builder
           .setType(EmbeddedDatabaseType.H2)
           .addScript("classpath:db-scripts/project-ddl.sql")
           .addScript("classpath:db-scripts/project-dml.sql")
           .build();
   log.info("Initiating the database from dbscript.");
   return db;
 }
  // jdbc:hsqldb:mem:testdb
  @Bean
  public DataSource dataSource() {

    // no need shutdown, EmbeddedDatabaseFactoryBean will take care of this
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase db =
        builder
            .setType(EmbeddedDatabaseType.HSQL)
            .addScript("db/sql/create-db.sql")
            .addScript("db/sql/insert-data.sql")
            .setName("NETTY_EXAMPLE_DB")
            .build();
    return db;
  }
 @Bean
 public DataSource dataSource() {
   boolean hsql = StringUtils.containsIgnoreCase(hibernateDialect, "hsql");
   boolean mysql = StringUtils.containsIgnoreCase(hibernateDialect, "mysql");
   if (hsql) {
     EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
     builder.setType(EmbeddedDatabaseType.HSQL);
     builder.addScript(embeddedDatabaseSchemaSQL);
     builder.addScript(embeddedDatabaseDataSQL);
     return builder.build();
   } else if (mysql) {
     DriverManagerDataSource dataSource = new DriverManagerDataSource();
     dataSource.setDriverClassName("com.mysql.jdbc.Driver");
     dataSource.setUrl("jdbc:mysql://localhost:3306/aj");
     dataSource.setUsername(user);
     dataSource.setPassword(password);
     return dataSource;
   } else {
     throw new IllegalStateException();
   }
 }
  @Bean
  public DataSource dataSource() {
    DataSource dataSource = null;
    if (env.getProperty("spring.database.vendor").equals(Database.H2.toString())) {

      EmbeddedDatabaseBuilder edb = new EmbeddedDatabaseBuilder();
      edb.setType(EmbeddedDatabaseType.H2);
      edb.addScript("classpath:db/h2/schema.sql");
      edb.addScript("classpath:db/h2/test-data.sql");
      EmbeddedDatabase embeddedDatabase = edb.build();

      dataSource = embeddedDatabase;

    } else if (env.getProperty("spring.database.vendor").equals(Database.POSTGRESQL.toString())) {

      // TODO Review all parameters for this class and update this setup as appropriate
      BasicDataSource basicDataSource = new BasicDataSource();
      basicDataSource.setDriverClassName(env.getProperty("db.jdbc.driverclass"));
      basicDataSource.setUrl(env.getProperty("db.jdbc.url"));
      basicDataSource.setUsername(env.getProperty("db.username"));
      basicDataSource.setPassword(env.getProperty("db.password"));
      // basicDataSource.setDefaultCatalog("ServerCommon");
      basicDataSource.setInitialSize(0);
      // basicDataSource.setMaxActive(this.dbConcurrentCallsMaxCalls + 8);  // This is for DBCB v1.4
      basicDataSource.setMaxTotal(10); // This is for DBCB v2.0 (API change)
      //		basicDataSource.setMaxIdle(this.dbConcurrentCallsMaxCalls / 2 + 8);
      basicDataSource.setMinIdle(0);
      // basicDataSource.setRemoveAbandoned(true);		// Can help to reduce chance of memory leaks //
      // This is for DBCB v1.4
      basicDataSource.setRemoveAbandonedTimeout(300); // this is the default (5 minutes)

      dataSource = basicDataSource;

    } else {
      logger.error("Unsupported database: {}", env.getProperty("spring.database.vendor"));
      throw new UnsupportedOperationException(
          "Unsupported database: " + env.getProperty("spring.database.vendor"));
    }
    return dataSource;
  }
 @Before
 public void setUp() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   database = builder.build();
   flyway = new Flyway();
   flyway.setInitVersion("1.5.2");
   flyway.setLocations("classpath:/org/cloudfoundry/identity/uaa/db/hsqldb/");
   flyway.setDataSource(database);
   flyway.migrate();
   JdbcTemplate jdbcTemplate = new JdbcTemplate(database);
   JdbcPagingListFactory pagingListFactory =
       new JdbcPagingListFactory(jdbcTemplate, new DefaultLimitSqlAdapter());
   db = new JdbcScimUserProvisioning(jdbcTemplate, pagingListFactory);
   db.setPasswordValidator(new NullPasswordValidator());
   gdb = new JdbcScimGroupProvisioning(jdbcTemplate, pagingListFactory);
   mdb = new JdbcScimGroupMembershipManager(jdbcTemplate, pagingListFactory);
   mdb.setScimUserProvisioning(db);
   mdb.setScimGroupProvisioning(gdb);
   userEndpoints = new ScimUserEndpoints();
   userEndpoints.setScimGroupMembershipManager(mdb);
   userEndpoints.setScimUserProvisioning(db);
 }
 @Bean
 public DataSource dataSource() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   return builder.setType(EmbeddedDatabaseType.H2).build();
 }
 @Bean
 public DataSource db() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.DERBY).build();
   return db;
 }
 @Bean
 public EmbeddedDatabase db() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   builder.setType(EmbeddedDatabaseType.H2).addScript("file:src/test/resources/schema_h2.sql");
   return builder.build();
 }
 @Bean
 public EmbeddedDatabase embeddedDatabase() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   builder.setType(EmbeddedDatabaseType.H2);
   return builder.build();
 }
 @Bean
 public DataSource dataSource() {
   EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
   return builder.setType(EmbeddedDatabaseType.H2).addScript("sql/create-db.sql").build();
 }