List of usage examples for org.apache.commons.dbcp2 BasicDataSource getInitialSize
@Override public synchronized int getInitialSize()
From source file:tilda.db.ConnectionPool.java
public static void init(String Id, String Driver, String DB, String User, String Pswd, int InitialSize, int MaxSize) { if (_DataSourcesById.get(Id) == null) synchronized (_DataSourcesById) { if (_DataSourcesById.get(Id) == null) // Definitely no connection pool by that name {/* ww w. ja v a 2 s. co m*/ String Sig = DB + "``" + User; BasicDataSource BDS = _DataSourcesBySig.get(Sig); // Let's see if that DB definition is already there if (BDS == null) { LOG.info("Initializing a fresh pool for Id=" + Id + ", DB=" + DB + ", User=" + User + ", and Pswd=Shhhhhhh!"); BDS = new BasicDataSource(); BDS.setDriverClassName(Driver); BDS.setUrl(DB); if (TextUtil.isNullOrEmpty(Pswd) == false && TextUtil.isNullOrEmpty(User) == false) { BDS.setUsername(User); BDS.setPassword(Pswd); } BDS.setInitialSize(InitialSize); BDS.setMaxTotal(MaxSize); BDS.setDefaultAutoCommit(false); BDS.setDefaultTransactionIsolation(java.sql.Connection.TRANSACTION_READ_COMMITTED); BDS.setDefaultQueryTimeout(20000); _DataSourcesBySig.put(Sig, BDS); } else { LOG.info("Merging pool with ID " + Id + " into prexisting pool " + Sig); if (BDS.getInitialSize() < InitialSize) BDS.setInitialSize(InitialSize); if (BDS.getMaxTotal() < MaxSize) BDS.setMaxTotal(MaxSize); } _DataSourcesById.put(Id, BDS); } } }