Hey,
I'm trying to configure DBCP so it create 10 connections when the
application is started, but i can't get it to work.
When the first user tries to log into the application, the 10 initial
connections are created. If i comment the "initialSize" parameter out,
the behaviour is the same.
I even created a servlet to ask for a hibernate session. When it is
started and ask for a session it seems the datasource "awakes" and
created the 10 initial connections.
These are the parameters passed to the DBCP through Tomcat's resource:
------------------------------------------------------------------------------
<Resource name="jdbc/mmw" auth="Container"
type="javax.sql.DataSource" />
<ResourceParams name="jdbc/mmw">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>username</name>
<value>user</value>
</parameter>
<parameter>
<name>password</name>
<value>pwd</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/mmw?autoReconnect=true</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>30</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<parameter>
<name>minIdle</name>
<value>10</value>
</parameter>
<!-- DOESN'T WORK - start -->
<parameter>
<name>initialSize</name>
<value>10</value>
</parameter>
<!-- DOESN'T WORK - end -->
<parameter>
<name>maxWait</name>
<value>3000</value>
</parameter>
<parameter>
<name>whenExhaustedAction</name>
<value>1</value>
</parameter>
<parameter>
<name>testOnBorrow</name>
<value>true</value>
</parameter>
<parameter>
<name>testOnReturn</name>
<value>false</value>
</parameter>
<parameter>
<name>validationQuery</name>
<value>SELECT 1</value>
</parameter>
<parameter>
<name>testWhileIdle</name>
<value>true</value>
</parameter>
<parameter>
<name>timeBetweenEvictionRunsMillis</name>
<value>8000</value>
</parameter>
<parameter>
<name>minEvictableIdleTimeMillis</name>
<value>20000</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>60</value>
</parameter>
<parameter>
<name>logAbandonedTimeout</name>
<value>true</value>
</parameter>
</ResourceParams>
------------------------------------------------------------------------------
The environment is:
Windows XP, jsdk1.4.2_07, Tomcat 5.0.28, commons-dbcp-1.2.2,
commons-pool-1.3, hibernate 2.1.7c, mysql-connector-java-5.0.5, MySQL 5.1.11
------------------------------------------------------------------------------
Am i doing something wrong or there really is a problem with DBCP's
"initialSize"?
Thank you for your time!
Rafael Leite