Hi David,

I suggest the following test which demonstrates that maxActive is not
checked properly without a line of Java code :
1/ Define a Datasource with an eviction policy configured :
<Resource id="jjsDS" type="DataSource">
  JdbcDriver com.mysql.jdbc.Driver
  JdbcUrl jdbc:mysql://localhost:3306/jjs?cacheResultsetMetadata=true
  UserName xxxx
  Password yyyy
  JtaManaged true
  InitialSize 5
  MaxActive 10
  MaxWait -1
  ValidationQuery SELECT 1
  TestOnBorrow false
  TestOnReturn false
  PoolPreparedStatements true
  MaxOpenPreparedStatements 10
  TimeBetweenEvictionRunsMillis 10000
  MinEvictableIdleTimeMillis 20000
  NumTestsPerEvictionRun 3
  TestWhileIdle false
  MinIdle 5
  MaxIdle 10
</Resource>
2/ Reference it from the persistence.xml of your application :
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence";
        version="1.0">
        <persistence-unit name="manager_bench" transaction-type="JTA">
                <provider>org.hibernate.ejb.HibernatePersistence</provider>
                <jta-data-source>java:openejb/Resource/jjsDS</jta-data-source>
        
<non-jta-data-source>java:openejb/Resource/jjsUnmanagedDS</non-jta-data-source>
                <!--
                <mapping-file>META-INF/orm.xml</mapping-file>
                -->
                <properties>
                        <property name="hibernate.dialect"
                                
value="org.hibernate.dialect.MySQLInnoDBDialect" />
                        <!-- property name="hibernate.hbm2ddl.auto" 
value="create-drop" -->
                        <property name="hibernate.show_sql" value="false" />
                        <property 
name="hibernate.transaction.manager_lookup_class"
                                
value="org.apache.openejb.hibernate.TransactionManagerLookup" />
                        <property name="hibernate.max_fetch_depth" value="2" />
                        <property name="hibernate.jdbc.batch_size" value="0" />
                        <property name="hibernate.cache.provider_class"
                                value="org.hibernate.cache.EhCacheProvider" />
                        <property name="hibernate.cache.use_query_cache"
                                value="true" />
                  <property name="hibernate.connection.release_mode"
                                value="auto" />
                </properties>
        </persistence-unit>
</persistence>

In that context, after the application deployment, you can see (with MySQL
Administrator for instance) that the number of connections to the database
never stops growing. Each time the evictor runs, a new slot of three 3
connections is opened (value of NumTestsPerEvictionRun). I've run the same
test againsts HSQLDB : the result is the same. A colleague has also
reproduced it.

We're going to spend some times this afternoon investigating what really
happens in DBCP and COMMON-POOLS. BTW do you know how we can access the JAVA
source of DBCP and COMMON-POOLS embedded in OPENJB 3.0 ?

Thanks in advance.
-- 
View this message in context: 
http://www.nabble.com/DataSource-configuration-for-production-tp17695975p17730022.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to