Dashboard > iBATIS DataMapper > Home > Frequently Asked Questions > How do I configure a Jakarta DBCP-datasource
How do I configure a Jakarta DBCP-datasource
Added by Niels Beekman, last edited by Niels Beekman on Sep 10, 2005  (view change)

The iBATIS documentation already provides information about configuring a DBCP-datasource, however, the implementation has been improved in the meantime to allow for more flexibility. The old (legacy) configuration is still supported, so if your needs are satisfied with the options mentioned in the documentation, read no further.

The old implementation uses the prefix 'Pool.' to pass settings to DBCP, these are hardcoded and are: ValidationQuery, MaximumActiveConnections, MaximumIdleConnections and MaximumWait. The following example illustrates the prefix:

<dataSource type="DBCP">
    <property name="JDBC.Driver" value="${driver}"/>
    <property name="JDBC.ConnectionURL" value="${url}"/>
    <property name="JDBC.Username" value="${username}"/>
    <property name="JDBC.Password" value="${password}"/>
    <property name="Pool.MaximumActiveConnections" value="10"/>

To achieve the same and more, use the new implementation, it uses Bean-style settings:

<dataSource type="DBCP">
    <property name="driverClassName" value="${driver}"/>
    <property name="url" value="${url}"/>
    <property name="username" value="${username}"/>
    <property name="password" value="${password}"/>
    <property name="maxActive" value="10"/>
    <property name="initialSize" value="5"/>
    <!-- Oracle specific for getString() / setString() CLOB-handling -->
    <property name="Driver.SetBigStringTryClob" value="true"/>

Notice the use of the property 'initialSize', this one could not be specified in the previous configuration. Additional driver-specific properties can now be specified too, these have to be prefixed with 'Driver.' (see example).

An exhaustive listing of all available properties can be found at the Commons DBCP projectsite: http://jakarta.apache.org/commons/dbcp/configuration.html

Site running on a free Atlassian Confluence Open Source Project License granted to OSS. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.5 Build:#811 Jul 25, 2007) - Bug/feature request - Contact Administrators