I have DBCP connection pooling working as follows using Tomcat 4.1.12:
Under the <Context> element for your application (this can either be in the
server.xml file or a separate xml file in the webapps dir) I have the
following config:
<Resource name="jdbc/XXXX" scope="Shareable"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/XXXX">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30000</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>100</value>
</parameter>
<parameter>
<name>username</name>
<value>theUser</value>
</parameter>
<parameter>
<name>password</name>
<value>thePassword</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:microsoft:sqlserver://hostname:port;databasename=myDB</value>
</parameter>
<parameter>
<name>validationQuery</name>
<value>select getdate()</value>
</parameter>
</ResourceParams>
This is an MS SQL Server config, but to change the db just make sure that
the requried JDBC jar file is in the common/lib directory and then change
the necessary elements above e.g. driverClassName etc.
In my web.xml for my app I have the following:
<resource-ref>
<res-ref-name>jdbc/XXXX</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
To use the pool I have the following code in a servlet: (I have left out
the try/catch block etc.)
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/XXXX");
conn = ds.getConnection();
....
Hope this helps.
Malcolm
-----Original Message-----
From: Sebastiªo Carlos Santos [mailto:[EMAIL PROTECTED]
Sent: 21 February 2003 00:15
To: [EMAIL PROTECTED]
Subject: Connection Pooling
Somebody has some experience or example in the
configuration and use of pool of connections with the
commons-dbcp.
I am a little lost and I don't know through where to
begin.
All information will be well arrival.
I thank the help in advance
__________________________________________________________________________
E-mail Premium BOL
Antiv�rus, anti-spam e at� 100 MB de espa�o. Assine j�!
http://email.bol.com.br/
---------------------------------------------------------------------
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]