views:

42

answers:

0

I want to execute an SQL statement on setup of each database connection. I'm using Spring 2.0.2 and org.apache.commons.dbcp.BasicDataSource from Apache Commons DBCP 1.2.1. BasicDataSource seems to have property connectionInitSqls, but only in the newer version... anyone knows a way to set something like that in the older version?

This is my datasource configuration in Spring applicationContext.xml:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.informix.jdbc.IfxDriver" />
    <property name="url" value="${dburl}" />
    <property name="username" value="${dbusername}" />
    <property name="password" value="${dbpassword}" />
    <property name="maxActive" value="30" />
    <property name="maxWait" value="5" />
    <property name="validationQuery" value="select 1 from systables where tabid = 1" />
    <property name="testWhileIdle" value="true" />
</bean>

EDIT: solved my problem by adding parameters to jdbc URL, however I'm still interested in answer if someone has it. I suppose that I could have extended BasicDataSource or its connection pool...