protected DataSource createDataSource ( DBType aDbType , String aDbUrl , String aUsername , String aPassword , Hashtable < String , DataSource > aDsTable ) throws SQLException { DataSource retDatasource ; String totalMaxPoolSizeName ; switch ( aDbType ) { case ORACLE : totalMaxPoolSizeName = ORACLE_MAX_POOL_SIZE_NAME ; break ; case MSSQL : totalMaxPoolSizeName = MSSQL_MAX_POOL_SIZE_NAME ; break ; case MYSQL : totalMaxPoolSizeName = MYSQL_MAX_POOL_SIZE_NAME ; break ; case SYBASE : totalMaxPoolSizeName = SYBASE_MAX_POOL_SIZE_NAME ; break ; case DB2 : totalMaxPoolSizeName = DB2_MAX_POOL_SIZE_NAME ; break ; case NETCOOL : totalMaxPoolSizeName = NETCOOL_MAX_POOL_SIZE_NAME ; break ; default : totalMaxPoolSizeName = CUSTOM_MAX_POOL_SIZE_NAME ; break ; } int totalMaxPoolSize = this . getPropIntValue ( totalMaxPoolSizeName , MAX_TOTAL_POOL_SIZE_DEFAULT_VALUE ) ; int perUserMaxPoolSize = this . getPropIntValue ( PooledDataSourceProvider . MAX_POOL_SIZE_NAME , PooledDataSourceProvider . MAX_POOL_SIZE_DEFAULT_VALUE ) ; int numDs = aDsTable . size ( ) ; int actualTotal = perUserMaxPoolSize * numDs ; if ( actualTotal >= totalMaxPoolSize ) { throw new TotalMaxPoolSizeExceedException ( "Can not create another datasource, the total max pool size exceeded. " + " Expected total max pool size = " + totalMaxPoolSize + " Actual total max pool size = " + actualTotal ) ; } retDatasource = this . createDataSource ( aDbType , aDbUrl , aUsername , aPassword ) ; return retDatasource ; }
create a new pooled datasource if total max pool size for the dbms is still ok . total max pool size per user < = total max pool size specified for specific db type . for example max pool size per user = 20 total max pool size for oracle dbms is 100 . only 5 datasource can be opened .