Пример #1
0
 public DataSource dataSource() {
   org.apache.tomcat.jdbc.pool.DataSource dataSource =
       new org.apache.tomcat.jdbc.pool.DataSource();
   DatabaseConfiguration conf = DatabaseConfiguration.getInstance();
   dataSource.setDriverClassName(conf.getDriverClassName());
   dataSource.setUsername(conf.getUsername());
   dataSource.setPassword(conf.getPassword());
   dataSource.setUrl(conf.getUrl());
   dataSource.setMaxActive(conf.getMaxActive());
   dataSource.setMaxIdle(conf.getMaxIdle());
   dataSource.setInitialSize(conf.getInitialSize());
   dataSource.setTestWhileIdle(conf.isTestWhileIdle());
   dataSource.setValidationQuery(conf.getValidationQuery());
   dataSource.setValidationInterval(conf.getValidationInterval());
   dataSource.setMaxAge(conf.getMaxAge());
   return dataSource;
 }
Пример #2
0
  @Bean(destroyMethod = "close")
  public DataSource dataSource() {
    DataSource dataSource = new DataSource();
    dataSource.setUrl(url);
    dataSource.setDriverClassName(driverClassName);
    dataSource.setUsername(username);
    dataSource.setPassword(password);
    dataSource.setMaxActive(maxActive);
    dataSource.setMaxIdle(maxIdle);
    dataSource.setMinIdle(minIdle);
    dataSource.setMaxWait(maxWait);
    dataSource.setDefaultAutoCommit(defaultAutoCommit);
    dataSource.setValidationQuery(validationQuery);
    dataSource.setValidationInterval(validationInterval);
    dataSource.setTestWhileIdle(testWhileIdle);
    dataSource.setLogAbandoned(logAbandoned);
    dataSource.setRemoveAbandoned(removeAbandoned);
    dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout);

    return dataSource;
  }