DriverAdapterCPDS driverAdapterCPDS = new DriverAdapterCPDS(); driverAdapterCPDS.setUrl(dataSourceProperties.getProperty("url")); driverAdapterCPDS.setUser(dataSourceProperties.getProperty("username")); driverAdapterCPDS.setPassword(dataSourceProperties.getProperty("password")); driverAdapterCPDS.setDriver(dataSourceProperties.getProperty("driverClass")); driverAdapterCPDS.setMaxActive(Integer.valueOf(dataSourceProperties.getProperty("maxActive"))); driverAdapterCPDS.setMaxIdle(Integer.valueOf(dataSourceProperties.getProperty("maxIdle"))); driverAdapterCPDS.setPoolPreparedStatements(Boolean.valueOf(dataSourceProperties.getProperty("poolPreparedStatements"))); SharedPoolDataSource poolDataSource = new SharedPoolDataSource(); poolDataSource.setConnectionPoolDataSource(driverAdapterCPDS); poolDataSource.setMaxWait(Integer.valueOf(dataSourceProperties.getProperty("maxWait"))); poolDataSource.setDefaultTransactionIsolation(Integer.valueOf(dataSourceProperties.getProperty("defaultTransactionIsolation"))); poolDataSource.setDefaultReadOnly(Boolean.valueOf(dataSourceProperties.getProperty("defaultReadOnly"))); poolDataSource.setTestOnBorrow(Boolean.valueOf(dataSourceProperties.getProperty("testOnBorrow"))); poolDataSource.setValidationQuery("SELECT 0");
cpds.setPassword("root"); SharedPoolDataSource tds = new SharedPoolDataSource(); tds.setConnectionPoolDataSource(cpds); tds.setMaxActive(10); tds.setMaxWait(50);
/** * This method is used internally by the class for * finding and removing the LRU Object. */ protected void removeLRU() { Object key = getFirstKey(); // be sure to call super.get(key), or you're likely to // get infinite promotion recursion Object value = super.get(key); remove(key); processRemovedLRU(key,value); }
private PoolKey getPoolKey(String username, String password) { return new PoolKey(getDataSourceName(), username); }
/** * Set the value of defaultAutoCommit, which defines the state of * connections handed out from this pool. The value can be changed * on the Connection using Connection.setAutoCommit(boolean). * The default is true. * * @param v Value to assign to defaultAutoCommit. */ public void setDefaultAutoCommit(boolean v) { assertInitializationAllowed(); this.defaultAutoCommit = v; }
/** * @see #getTestOnBorrow */ public final boolean isTestOnBorrow() { return getTestOnBorrow(); }
/** * Get the number of active connections in the default pool. */ public int getNumActive() { return getNumActive(null, null); }
/** * Get the number of idle connections in the default pool. */ public int getNumIdle() { return getNumIdle(null, null); }
/** * 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; }
/** * Attempt to establish a database connection. */ public Connection getConnection() throws SQLException { return getConnection(null, null); }
/** * The maximum number of active connections that can remain idle in the * pool, without extra ones being released, or negative for no limit. * The default is 8. */ public void setMaxIdle(int maxIdle) { assertInitializationAllowed(); this.maxIdle = maxIdle; }
/** * Implements {@link Map#remove(Object)}. */ public Object remove(Object key) { Entry e = removeImpl(key); return (e == null) ? null : e.getValue(); }
private PoolKey getPoolKey(String username, String password) { return new PoolKey(getDataSourceName(), username); }
/** * Set the value of defaultReadOnly, which defines the state of * connections handed out from this pool. The value can be changed * on the Connection using Connection.setReadOnly(boolean). * The default is false. * * @param v Value to assign to defaultReadOnly. */ public void setDefaultReadOnly(boolean v) { assertInitializationAllowed(); this.defaultReadOnly = v; }
/** * @see #getTestOnBorrow */ public final boolean isTestOnBorrow() { return getTestOnBorrow(); }
/** * Get the number of active connections in the default pool. */ public int getNumActive() { return getNumActive(null, null); }
/** * Get the number of idle connections in the default pool. */ public int getNumIdle() { return getNumIdle(null, null); }
/** * Set the value of defaultReadOnly, which defines the state of * connections handed out from this pool. The value can be changed * on the Connection using Connection.setReadOnly(boolean). * The default is false. * * @param v Value to assign to defaultReadOnly. */ public void setDefaultReadOnly(boolean v) { assertInitializationAllowed(); this.defaultReadOnly = v; }