Set the "testWhileIdle" to test a few connections every so often. It will eject dead connections from the pool.
-----Original Message----- From: Martin Wingert [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 30, 2008 8:01 AM To: [email protected] Subject: [DBCP] connections not properly closed I'm running dbcp 1.2.2 and mysql-connector-java-5.1.6 on a test system. Just found that the system after running a couple of hours got an exception in the log files when trying to create a new database connection: java.net.SocketException: Too many open files Checked the list of open files (lsof) and got a long list: java 10659 admin 6u sock 0,4 1555102 can't identify protocol The PID is the jvm running our system. Found that the MySQL setting wait_timeout (that closes idle connections after the configured time) was set to 60 seconds by accident. So it seems that when MySQL closes an idle connection somehow the JDBC connection in the database pool isn't closed properly leaving the file descriptor open (this is a test system so there are many idle connections). This is the code I use to setup my pool: GenericObjectPool m_generic_objectpool = new GenericObjectPool(); m_generic_objectpool.setMaxActive(connection_timeout); m_generic_objectpool.setMaxWait(max_wait); m_generic_objectpool.setTestOnBorrow(true); m_generic_objectpool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAU STED_BLOCK); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(full_url,conProp); AbandonedConfig ab_conf = new AbandonedConfig(); ab_conf.setRemoveAbandonedTimeout(m_dbpool_abandoned_timeout); ab_conf.setRemoveAbandoned(m_dbpool_close_abandoned); String validation_query = new String("SELECT 1"); new PoolableConnectionFactory(connectionFactory,m_generic_objectpool,null,va lidation_query,false,true,ab_conf); PoolingDataSource data_source = new PoolingDataSource(m_generic_objectpool); Thankful for any help BR // Martin --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
