コード例 #1
0
 private HikariDataSource createDataSource(int minSize, int maxSize) {
   HikariDataSource dataSource =
       (HikariDataSource) initializeBuilder().type(HikariDataSource.class).build();
   dataSource.setMinimumIdle(minSize);
   dataSource.setMaximumPoolSize(maxSize);
   return dataSource;
 }
コード例 #2
0
 /**
  * Configure datasource.
  *
  * @return datasource
  * @throws PropertyVetoException
  */
 @Bean(destroyMethod = "close")
 public DataSource dataSource() throws PropertyVetoException {
   HikariDataSource dataSource = new HikariDataSource();
   dataSource.setDriverClassName(environment.getProperty("jdbc.driverClass"));
   dataSource.setJdbcUrl(environment.getProperty("jdbc.url"));
   dataSource.setUsername(environment.getProperty("jdbc.user"));
   dataSource.setPassword(environment.getProperty("jdbc.password"));
   dataSource.setMinimumIdle(environment.getProperty("datasource.pool.min_size", Integer.class));
   dataSource.setMaximumPoolSize(
       environment.getProperty("datasource.pool.max_size", Integer.class));
   return dataSource;
 }