private PGPoolingDataSource createDataSource(String dbName) {
   PGPoolingDataSource dataSource;
   dataSource = new PGPoolingDataSource();
   dataSource.setUser("admin");
   dataSource.setPassword("admin");
   dataSource.setServerName("localhost");
   dataSource.setDatabaseName(dbName);
   return dataSource;
 }
 @Bean
 public DataSource dataSource() {
   final PGPoolingDataSource source = new PGPoolingDataSource();
   source.setDataSourceName("cloudoholiq");
   source.setServerName("localhost");
   source.setDatabaseName("cloudoholiq");
   source.setUser("postgres");
   source.setPassword("postgres");
   source.setMaxConnections(10);
   return source;
 }
  @Bean(destroyMethod = "close")
  DataSource dataSource(Environment env) throws IllegalStateException, SQLException {

    PGPoolingDataSource pgPoolingDataSource = new PGPoolingDataSource();
    pgPoolingDataSource.setUrl(env.getRequiredProperty("db.url"));
    pgPoolingDataSource.setUser(env.getRequiredProperty("db.username"));
    pgPoolingDataSource.setPassword(env.getRequiredProperty("db.password"));
    pgPoolingDataSource.setInitialConnections(
        Integer.parseInt(env.getRequiredProperty("db.pool_size")));
    return pgPoolingDataSource;
  }
Exemple #4
0
 public DBConnection() {
   source = new PGPoolingDataSource();
   // source.setDataSourceName("A Data Source");
   source.setServerName(this.HOST);
   source.setPortNumber(this.PORT);
   source.setDatabaseName(this.DB);
   source.setUser(this.USER);
   source.setPassword(this.PASSWORD);
   // source.setMaxConnections(20);//Максимальное значение
   source.setInitialConnections(1); // Сколько соединений будет сразу открыто
 }
Exemple #5
0
 public static DataSource dataSource(Properties properties) throws IOException {
   String jdbcUrl = properties.getProperty("revenj.jdbcUrl");
   if (jdbcUrl == null) {
     throw new IOException("revenj.jdbcUrl is missing from Properties");
   }
   org.postgresql.ds.PGPoolingDataSource dataSource = new PGPoolingDataSource();
   dataSource.setUrl(jdbcUrl);
   String user = properties.getProperty("user");
   String revUser = properties.getProperty("revenj.user");
   if (revUser != null && revUser.length() > 0) {
     dataSource.setUser(revUser);
   } else if (user != null && user.length() > 0) {
     dataSource.setUser(user);
   }
   String password = properties.getProperty("password");
   String revPassword = properties.getProperty("revenj.password");
   if (revPassword != null && revPassword.length() > 0) {
     dataSource.setPassword(revPassword);
   } else if (password != null && password.length() > 0) {
     dataSource.setPassword(password);
   }
   return dataSource;
 }