Java Code Examples for io.dropwizard.db.DataSourceFactory#setInitialSize()
The following examples show how to use
io.dropwizard.db.DataSourceFactory#setInitialSize() .
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: JDBIOptionalInstantTest.java From dropwizard-java8 with Apache License 2.0 | 6 votes |
@Before public void setupTests() throws IOException { final DataSourceFactory dataSourceFactory = new DataSourceFactory(); dataSourceFactory.setDriverClass("org.h2.Driver"); dataSourceFactory.setUrl("jdbc:h2:mem:date-time-optional-" + System.currentTimeMillis() + "?user=sa"); dataSourceFactory.setInitialSize(1); final DBI dbi = new DBIFactory().build(env, dataSourceFactory, "test"); try (Handle h = dbi.open()) { h.execute("CREATE TABLE tasks (" + "id INT PRIMARY KEY, " + "assignee VARCHAR(255) NOT NULL, " + "start_date TIMESTAMP, " + "end_date TIMESTAMP, " + "comments VARCHAR(1024) " + ")"); } dao = dbi.onDemand(TaskDao.class); }
Example 2
Source File: JDBIOptionalLocalDateTimeTest.java From dropwizard-java8 with Apache License 2.0 | 6 votes |
@Before public void setupTests() throws IOException { final DataSourceFactory dataSourceFactory = new DataSourceFactory(); dataSourceFactory.setDriverClass("org.h2.Driver"); dataSourceFactory.setUrl("jdbc:h2:mem:date-time-optional-" + System.currentTimeMillis() + "?user=sa"); dataSourceFactory.setInitialSize(1); final DBI dbi = new DBIFactory().build(env, dataSourceFactory, "test"); try (Handle h = dbi.open()) { h.execute("CREATE TABLE tasks (" + "id INT PRIMARY KEY, " + "assignee VARCHAR(255) NOT NULL, " + "start_date TIMESTAMP, " + "end_date TIMESTAMP, " + "comments VARCHAR(1024) " + ")"); } dao = dbi.onDemand(TaskDao.class); }
Example 3
Source File: JDBIOptionalLocalDateTest.java From dropwizard-java8 with Apache License 2.0 | 6 votes |
@Before public void setupTests() throws IOException { final DataSourceFactory dataSourceFactory = new DataSourceFactory(); dataSourceFactory.setDriverClass("org.h2.Driver"); dataSourceFactory.setUrl("jdbc:h2:mem:date-time-optional-" + System.currentTimeMillis() + "?user=sa"); dataSourceFactory.setInitialSize(1); final DBI dbi = new DBIFactory().build(env, dataSourceFactory, "test"); try (Handle h = dbi.open()) { h.execute("CREATE TABLE tasks (" + "id INT PRIMARY KEY, " + "assignee VARCHAR(255) NOT NULL, " + "start_date TIMESTAMP, " + "end_date TIMESTAMP, " + "comments VARCHAR(1024) " + ")"); } dao = dbi.onDemand(TaskDao.class); }
Example 4
Source File: EbeanBundle.java From dropwizard-experiment with MIT License | 6 votes |
private static void applyMigrations(DataSourceFactory dbConfig, MetricRegistry metrics) throws Exception { Stopwatch migrationsTimer = Stopwatch.createStarted(); // Borrowed from AbstractLiquibaseCommand. DataSourceFactory lbConfig = EbeanConfigUtils.clone(dbConfig); lbConfig.setMaxSize(1); lbConfig.setMinSize(1); lbConfig.setInitialSize(1); try (CloseableLiquibase liquibase = new CloseableLiquibase(dbConfig.build(metrics, "liquibase"))) { log.info("Checking for database migrations."); liquibase.update(""); migrationsTimer.stop(); metrics.timer(MetricRegistry.name(EbeanBundle.class, "migrations")).update(migrationsTimer.elapsed(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS); log.info("Database migrations complete in {} ms.", migrationsTimer.elapsed(TimeUnit.MILLISECONDS)); } catch (ValidationFailedException e) { e.printDescriptiveError(System.err); throw e; } }
Example 5
Source File: EbeanConfigUtils.java From dropwizard-experiment with MIT License | 5 votes |
public static DataSourceFactory clone(DataSourceFactory dbConfig) { DataSourceFactory newConfig = new DataSourceFactory(); newConfig.setUser(dbConfig.getUser()); newConfig.setPassword(dbConfig.getPassword()); newConfig.setUrl(dbConfig.getUrl()); newConfig.setDriverClass(dbConfig.getDriverClass()); newConfig.setMaxSize(dbConfig.getMaxSize()); newConfig.setMinSize(dbConfig.getMinSize()); newConfig.setInitialSize(dbConfig.getInitialSize()); return newConfig; }