/** * The maximum number of active connections that can be allocated from * this pool at the same time, or non-positive for no limit. * This value is used for any username which is not specified * in perUserMaxConnections. The default is 8. */ public void setDefaultMaxActive(int maxActive) { assertInitializationAllowed(); this.defaultMaxActive = maxActive; }
ConnectionPoolDataSource cpds = testCPDS(username, password); Integer userMax = getPerUserMaxActive(username); int maxActive = (userMax == null) ? getDefaultMaxActive() : userMax.intValue(); userMax = getPerUserMaxIdle(username); int maxIdle = (userMax == null) ? getDefaultMaxIdle() : userMax.intValue(); userMax = getPerUserMaxWait(username); int maxWait = (userMax == null) ? getDefaultMaxWait() : userMax.intValue(); pool.setMaxIdle(maxIdle); pool.setMaxWait(maxWait); pool.setWhenExhaustedAction(whenExhaustedAction(maxActive, maxWait)); pool.setTestOnBorrow(getTestOnBorrow()); pool.setTestOnReturn(getTestOnReturn()); pool.setTimeBetweenEvictionRunsMillis( getTimeBetweenEvictionRunsMillis()); pool.setNumTestsPerEvictionRun(getNumTestsPerEvictionRun()); pool.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis()); pool.setTestWhileIdle(getTestWhileIdle()); new CPDSConnectionFactory(cpds, pool, getValidationQuery(), isRollbackAfterValidation(), username, password); pools.put(getPoolKey(username), pool);
PerUserPoolDataSource perUserPoolDataSource = new PerUserPoolDataSource(); perUserPoolDataSource.setConnectionPoolDataSource(adapterCPDS); perUserPoolDataSource.setDefaultMaxActive(dataSourceInformation.getMaxActive()); perUserPoolDataSource.setDefaultMaxIdle(dataSourceInformation.getMaxIdle()); perUserPoolDataSource.setDefaultMaxWait((int) dataSourceInformation.getMaxWait()); perUserPoolDataSource.setDefaultAutoCommit(dataSourceInformation.isDefaultAutoCommit()); perUserPoolDataSource.setDefaultReadOnly(dataSourceInformation.isDefaultReadOnly()); perUserPoolDataSource.setTestOnBorrow(dataSourceInformation.isTestOnBorrow()); perUserPoolDataSource.setTestOnReturn(dataSourceInformation.isTestOnReturn()); perUserPoolDataSource.setTestWhileIdle(dataSourceInformation.isTestWhileIdle()); perUserPoolDataSource.setMinEvictableIdleTimeMillis( (int) dataSourceInformation.getMinEvictableIdleTimeMillis()); perUserPoolDataSource.setTimeBetweenEvictionRunsMillis( (int) dataSourceInformation.getTimeBetweenEvictionRunsMillis()); perUserPoolDataSource.setNumTestsPerEvictionRun( dataSourceInformation.getNumTestsPerEvictionRun()); perUserPoolDataSource.setDefaultTransactionIsolation(defaultTransactionIsolation); perUserPoolDataSource.setValidationQuery(validationQuery);
protected void setupDefaults(Connection con, String username) throws SQLException { boolean defaultAutoCommit = isDefaultAutoCommit(); if (username != null) { Boolean userMax = getPerUserDefaultAutoCommit(username); if (userMax != null) { defaultAutoCommit = userMax.booleanValue(); } } boolean defaultReadOnly = isDefaultReadOnly(); if (username != null) { Boolean userMax = getPerUserDefaultReadOnly(username); if (userMax != null) { defaultReadOnly = userMax.booleanValue(); } } int defaultTransactionIsolation = getDefaultTransactionIsolation(); if (username != null) { Integer userMax = getPerUserDefaultTransactionIsolation(username); if (userMax != null) { defaultTransactionIsolation = userMax.intValue(); } } con.setAutoCommit(defaultAutoCommit); if (defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION) { con.setTransactionIsolation(defaultTransactionIsolation); } con.setReadOnly(defaultReadOnly); }
protected InstanceKeyDataSource getNewInstance(Reference ref) throws IOException, ClassNotFoundException { PerUserPoolDataSource pupds = new PerUserPoolDataSource(); RefAddr ra = ref.get("defaultMaxActive"); if (ra != null && ra.getContent() != null) { pupds.setDefaultMaxActive( Integer.parseInt(ra.getContent().toString())); pupds.setDefaultMaxIdle( Integer.parseInt(ra.getContent().toString())); pupds.setDefaultMaxWait( Integer.parseInt(ra.getContent().toString()));
/** * Initializes the Jdbc2PoolDataSource. * * @param configuration where to read the settings from * @throws TorqueException if a property set fails * @return a configured <code>Jdbc2PoolDataSource</code> */ private PerUserPoolDataSource initJdbc2Pool(Configuration configuration) throws TorqueException { log.debug("Starting initJdbc2Pool"); PerUserPoolDataSource dataSource = new PerUserPoolDataSource(); Configuration c = Torque.getConfiguration(); if (c == null || c.isEmpty()) { log.warn("Global Configuration not set," + " no Default pool data source configured!"); } else { Configuration conf = c.subset(DEFAULT_POOL_KEY); applyConfiguration(conf, dataSource); } Configuration conf = configuration.subset(POOL_KEY); applyConfiguration(conf, dataSource); return dataSource; }
private PoolKey getPoolKey(String username, String password) { return new PoolKey(getDataSourceName(), username); }
ConnectionPoolDataSource cpds = testCPDS(username, password); Integer userMax = getPerUserMaxActive(username); int maxActive = (userMax == null) ? getDefaultMaxActive() : userMax.intValue(); userMax = getPerUserMaxIdle(username); int maxIdle = (userMax == null) ? getDefaultMaxIdle() : userMax.intValue(); userMax = getPerUserMaxWait(username); int maxWait = (userMax == null) ? getDefaultMaxWait() : userMax.intValue(); pool.setMaxIdle(maxIdle); pool.setMaxWait(maxWait); pool.setWhenExhaustedAction(whenExhaustedAction(maxActive, maxWait)); pool.setTestOnBorrow(getTestOnBorrow()); pool.setTestOnReturn(getTestOnReturn()); pool.setTimeBetweenEvictionRunsMillis( getTimeBetweenEvictionRunsMillis()); pool.setNumTestsPerEvictionRun(getNumTestsPerEvictionRun()); pool.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis()); pool.setTestWhileIdle(getTestWhileIdle()); CPDSConnectionFactory factory = new CPDSConnectionFactory(cpds, pool, getValidationQuery(), isRollbackAfterValidation(), username, password); Object old = managers.put(getPoolKey(username,password), factory); if (old != null) { throw new IllegalStateException("Pool already contains an entry for this user/password: "+username);
PerUserPoolDataSource perUserPoolDataSource = new PerUserPoolDataSource(); perUserPoolDataSource.setConnectionPoolDataSource(adapterCPDS); perUserPoolDataSource.setDefaultMaxActive(dataSourceInformation.getMaxActive()); perUserPoolDataSource.setDefaultMaxIdle(dataSourceInformation.getMaxIdle()); perUserPoolDataSource.setDefaultMaxWait((int) dataSourceInformation.getMaxWait()); perUserPoolDataSource.setDefaultAutoCommit(dataSourceInformation.isDefaultAutoCommit()); perUserPoolDataSource.setDefaultReadOnly(dataSourceInformation.isDefaultReadOnly()); perUserPoolDataSource.setTestOnBorrow(dataSourceInformation.isTestOnBorrow()); perUserPoolDataSource.setTestOnReturn(dataSourceInformation.isTestOnReturn()); perUserPoolDataSource.setTestWhileIdle(dataSourceInformation.isTestWhileIdle()); perUserPoolDataSource.setMinEvictableIdleTimeMillis( (int) dataSourceInformation.getMinEvictableIdleTimeMillis()); perUserPoolDataSource.setTimeBetweenEvictionRunsMillis( (int) dataSourceInformation.getTimeBetweenEvictionRunsMillis()); perUserPoolDataSource.setNumTestsPerEvictionRun( dataSourceInformation.getNumTestsPerEvictionRun()); perUserPoolDataSource.setDefaultTransactionIsolation(defaultTransactionIsolation); perUserPoolDataSource.setValidationQuery(validationQuery);
protected void setupDefaults(Connection con, String username) throws SQLException { boolean defaultAutoCommit = isDefaultAutoCommit(); if (username != null) { Boolean userMax = getPerUserDefaultAutoCommit(username); if (userMax != null) { defaultAutoCommit = userMax.booleanValue(); boolean defaultReadOnly = isDefaultReadOnly(); if (username != null) { Boolean userMax = getPerUserDefaultReadOnly(username); if (userMax != null) { defaultReadOnly = userMax.booleanValue(); int defaultTransactionIsolation = getDefaultTransactionIsolation(); if (username != null) { Integer userMax = getPerUserDefaultTransactionIsolation(username); if (userMax != null) { defaultTransactionIsolation = userMax.intValue();
protected InstanceKeyDataSource getNewInstance(Reference ref) throws IOException, ClassNotFoundException { PerUserPoolDataSource pupds = new PerUserPoolDataSource(); RefAddr ra = ref.get("defaultMaxActive"); if (ra != null && ra.getContent() != null) { pupds.setDefaultMaxActive( Integer.parseInt(ra.getContent().toString())); pupds.setDefaultMaxIdle( Integer.parseInt(ra.getContent().toString())); pupds.setDefaultMaxWait( Integer.parseInt(ra.getContent().toString()));
private PoolKey getPoolKey(String username, String password) { return new PoolKey(getDataSourceName(), username); }
ConnectionPoolDataSource cpds = testCPDS(username, password); Integer userMax = getPerUserMaxActive(username); int maxActive = (userMax == null) ? getDefaultMaxActive() : userMax.intValue(); userMax = getPerUserMaxIdle(username); int maxIdle = (userMax == null) ? getDefaultMaxIdle() : userMax.intValue(); userMax = getPerUserMaxWait(username); int maxWait = (userMax == null) ? getDefaultMaxWait() : userMax.intValue(); pool.setMaxIdle(maxIdle); pool.setMaxWait(maxWait); pool.setWhenExhaustedAction(whenExhaustedAction(maxActive, maxWait)); pool.setTestOnBorrow(getTestOnBorrow()); pool.setTestOnReturn(getTestOnReturn()); pool.setTimeBetweenEvictionRunsMillis( getTimeBetweenEvictionRunsMillis()); pool.setNumTestsPerEvictionRun(getNumTestsPerEvictionRun()); pool.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis()); pool.setTestWhileIdle(getTestWhileIdle()); CPDSConnectionFactory factory = new CPDSConnectionFactory(cpds, pool, getValidationQuery(), isRollbackAfterValidation(), username, password); Object old = managers.put(getPoolKey(username,password), factory); if (old != null) { throw new IllegalStateException("Pool already contains an entry for this user/password: "+username);
protected void setupDefaults(Connection con, String username) throws SQLException { boolean defaultAutoCommit = isDefaultAutoCommit(); if (username != null) { Boolean userMax = getPerUserDefaultAutoCommit(username); if (userMax != null) { defaultAutoCommit = userMax.booleanValue(); boolean defaultReadOnly = isDefaultReadOnly(); if (username != null) { Boolean userMax = getPerUserDefaultReadOnly(username); if (userMax != null) { defaultReadOnly = userMax.booleanValue(); int defaultTransactionIsolation = getDefaultTransactionIsolation(); if (username != null) { Integer userMax = getPerUserDefaultTransactionIsolation(username); if (userMax != null) { defaultTransactionIsolation = userMax.intValue();
protected InstanceKeyDataSource getNewInstance(Reference ref) throws IOException, ClassNotFoundException { PerUserPoolDataSource pupds = new PerUserPoolDataSource(); RefAddr ra = ref.get("defaultMaxActive"); if (ra != null && ra.getContent() != null) { pupds.setDefaultMaxActive( Integer.parseInt(ra.getContent().toString())); pupds.setDefaultMaxIdle( Integer.parseInt(ra.getContent().toString())); pupds.setDefaultMaxWait( Integer.parseInt(ra.getContent().toString()));
/** * The maximum number of active connections that can remain idle in the * pool, without extra ones being released, or negative for no limit. * This value is used for any username which is not specified * in perUserMaxIdle. The default is 8. */ public void setDefaultMaxIdle(int defaultMaxIdle) { assertInitializationAllowed(); this.defaultMaxIdle = defaultMaxIdle; }
private PoolKey getPoolKey(String username) { PoolKey key = null; String dsName = getDataSourceName(); Map dsMap = (Map) poolKeys.get(dsName); if (dsMap != null) { key = (PoolKey) dsMap.get(username); } if (key == null) { key = new PoolKey(dsName, username); if (dsMap == null) { dsMap = new HashMap(); poolKeys.put(dsName, dsMap); } dsMap.put(username, key); } return key; }
/** * The maximum number of milliseconds that the pool will wait (when there * are no available connections) for a connection to be returned before * throwing an exception, or -1 to wait indefinitely. Will fail * immediately if value is 0. * This value is used for any username which is not specified * in perUserMaxWait. The default is -1. */ public void setDefaultMaxWait(int defaultMaxWait) { assertInitializationAllowed(); this.defaultMaxWait = defaultMaxWait; }
/** * The maximum number of active connections that can remain idle in the * pool, without extra ones being released, or negative for no limit. * This value is used for any username which is not specified * in perUserMaxIdle. The default is 8. */ public void setDefaultMaxIdle(int defaultMaxIdle) { assertInitializationAllowed(); this.defaultMaxIdle = defaultMaxIdle; }
/** * The maximum number of milliseconds that the pool will wait (when there * are no available connections) for a connection to be returned before * throwing an exception, or -1 to wait indefinitely. Will fail * immediately if value is 0. * This value is used for any username which is not specified * in perUserMaxWait. The default is -1. */ public void setDefaultMaxWait(int defaultMaxWait) { assertInitializationAllowed(); this.defaultMaxWait = defaultMaxWait; }