Délai d'attente pour objet inactif Apache Pool de connexion

J'ai créé un Pool à l'aide de ConnectionPool comme ceci:

Je créer un certain taks à getConection à partir de la base de données et excute. Je ne lance mon application que 3 fois, ma demande throws Exception.

PoolableObjectFactory mySqlPoolableObjectFactory = new MySqlPoolableObjectFactory(
            host, dbName, user, password);
    Config config = new GenericObjectPool.Config();
    config.maxActive = 10;
    config.testOnBorrow = true;
    config.testWhileIdle = true;
    config.maxIdle = 5;
    config.minIdle = 1;
    config.maxWait = 10000;
    config.timeBetweenEvictionRunsMillis = 10000;
    config.minEvictableIdleTimeMillis = 60000;

    GenericObjectPoolFactory genericObjectPoolFactory = new GenericObjectPoolFactory(
            mySqlPoolableObjectFactory, config);
    return genericObjectPoolFactory.createPool();

public Connection getConnectionFromPool() {

    Connection conn = null;

    try {

        conn = (Connection) connPool.borrowObject();

    } catch (Exception e) {

        e.printStackTrace();

    }

    return conn;
}

Mais quand je lance beaucoup de fil. Il jeter Exeption

java.util.NoSuchElementException: Timeout waiting for idle object
    at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1174)
    at vn.vccorp.bigdata.mysql.AdmarketPool.getConnectionFromPool(AdmarketPool.java:76)
avez-vous le retour des objets de la piscine à l'aide de returnObject méthode?
Oui, j'ai toujours fermer la connexion après la fin de mon sql à l'aide de public void safeClose(Connection conn) { if (conn != null) { try { connPool.returnObject(conn); } catch (Exception e) { e.printStackTrace(); } } }

OriginalL'auteur phuongdo | 2012-08-03