private Object loadPoolingDataSource(Reference ref) { // If DataSource exists, return it String name = getProperty(ref, "dataSourceName"); PGPoolingDataSource pds = PGPoolingDataSource.getDataSource(name); if (pds != null) { return pds; } // Otherwise, create a new one pds = new PGPoolingDataSource(); pds.setDataSourceName(name); loadBaseDataSource(pds, ref); String min = getProperty(ref, "initialConnections"); if (min != null) { pds.setInitialConnections(Integer.parseInt(min)); } String max = getProperty(ref, "maxConnections"); if (max != null) { pds.setMaxConnections(Integer.parseInt(max)); } return pds; }
private Object loadPoolingDataSource(Reference ref) { // If DataSource exists, return it String name = getProperty(ref, "dataSourceName"); PGPoolingDataSource pds = PGPoolingDataSource.getDataSource(name); if (pds != null) { return pds; } // Otherwise, create a new one pds = new PGPoolingDataSource(); pds.setDataSourceName(name); loadBaseDataSource(pds, ref); String min = getProperty(ref, "initialConnections"); if (min != null) { pds.setInitialConnections(Integer.parseInt(min)); } String max = getProperty(ref, "maxConnections"); if (max != null) { pds.setMaxConnections(Integer.parseInt(max)); } return pds; }
@Override public DataSource createDataSource(Properties properties) throws SQLException { if (properties == null) { properties = new Properties(); } if(properties.getProperty(JDBC_DATASOURCE_NAME) == null) { properties.setProperty(JDBC_DATASOURCE_NAME, DataSourceFactoryImpl.class.getSimpleName() + "_" + dataSourceCount.getAndAdd(1)); } PGPoolingDataSource dataSource = PGPoolingDataSource.getDataSource(properties.getProperty(JDBC_DATASOURCE_NAME)); if(dataSource == null) { dataSource = new PGPoolingDataSource(); // Set dataSourceName, databaseName, user, and password dataSource.setDataSourceName(properties.getProperty(JDBC_DATASOURCE_NAME)); String url = properties.getProperty(JDBC_URL); if(url != null) { dataSource.setUrl(url); } dataSource.setPortNumber(Integer.valueOf(properties.getProperty(JDBC_PORT_NUMBER, Integer.toString(dataSource.getPortNumber())))); dataSource.setServerName(properties.getProperty(JDBC_SERVER_NAME, dataSource.getServerName())); dataSource.setUser(properties.getProperty(JDBC_USER, dataSource.getUser())); dataSource.setPassword(properties.getProperty(JDBC_PASSWORD, dataSource.getPassword())); dataSource.setDatabaseName(properties.getProperty(JDBC_DATABASE_NAME, dataSource.getDatabaseName())); } return new DataSourceWrapper(dataSource); }
@Override public DataSource createDataSource(Properties properties) throws SQLException { if (properties == null) { properties = new Properties(); } if(properties.getProperty(JDBC_DATASOURCE_NAME) == null) { properties.setProperty(JDBC_DATASOURCE_NAME, DataSourceFactoryImpl.class.getSimpleName() + "_" + dataSourceCount.getAndAdd(1)); } PGPoolingDataSource dataSource = PGPoolingDataSource.getDataSource(properties.getProperty(JDBC_DATASOURCE_NAME)); if(dataSource == null) { dataSource = new PGPoolingDataSource(); // Set dataSourceName, databaseName, user, and password dataSource.setDataSourceName(properties.getProperty(JDBC_DATASOURCE_NAME)); String url = properties.getProperty(JDBC_URL); if(url != null) { dataSource.setUrl(url); } dataSource.setPortNumber(Integer.valueOf(properties.getProperty(JDBC_PORT_NUMBER, Integer.toString(dataSource.getPortNumber())))); dataSource.setServerName(properties.getProperty(JDBC_SERVER_NAME, dataSource.getServerName())); dataSource.setUser(properties.getProperty(JDBC_USER, dataSource.getUser())); dataSource.setPassword(properties.getProperty(JDBC_PASSWORD, dataSource.getPassword())); dataSource.setDatabaseName(properties.getProperty(JDBC_DATABASE_NAME, dataSource.getDatabaseName())); } return new DataSourceWrapper(dataSource); }
private Object loadPoolingDataSource(Reference ref) { // If DataSource exists, return it String name = getProperty(ref, "dataSourceName"); PGPoolingDataSource pds = PGPoolingDataSource.getDataSource(name); if (pds != null) { return pds; } // Otherwise, create a new one pds = new PGPoolingDataSource(); pds.setDataSourceName(name); loadBaseDataSource(pds, ref); String min = getProperty(ref, "initialConnections"); if (min != null) { pds.setInitialConnections(Integer.parseInt(min)); } String max = getProperty(ref, "maxConnections"); if (max != null) { pds.setMaxConnections(Integer.parseInt(max)); } return pds; }
private Object loadPoolingDataSource(Reference ref) { // If DataSource exists, return it String name = getProperty(ref, "dataSourceName"); PGPoolingDataSource pds = PGPoolingDataSource.getDataSource(name); if (pds != null) { return pds; } // Otherwise, create a new one pds = new PGPoolingDataSource(); pds.setDataSourceName(name); loadBaseDataSource(pds, ref); String min = getProperty(ref, "initialConnections"); if (min != null) { pds.setInitialConnections(Integer.parseInt(min)); } String max = getProperty(ref, "maxConnections"); if (max != null) { pds.setMaxConnections(Integer.parseInt(max)); } return pds; }