commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ben short" <>
Subject [DBCP] BasicDataSource, testOnBorrow and PostgreSQL
Date Fri, 19 Sep 2008 20:36:26 GMT

I'm trying to use the BasicDataSource to pool PostgreSQL connections.
I'm also using Spring and Hibernate.

My BasicDataSource configuration is as follows....

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="org.postgresql.Driver"/>
        <property name="url"
        <property name="validationQuery" value="SELECT 1"/>
        <property name="initialSize" value="5"/>
        <property name="maxActive" value="25"/>
        <property name="minIdle" value="5"/>
        <property name="maxIdle" value="5"/>
        <property name="defaultAutoCommit" value="false"/>
        <property name="testOnBorrow" value="true"/>

The problem I have is that springs transaction manager is trying to
set the transaction isolation based on transactional annotations in my
code. But I get the following exception thrown.

org.postgresql.util.PSQLException: Cannot change transaction isolation
level in the middle of a transaction

I have debugged the code and see that when the validateConnection
method gets called on the PoolableConnectionFactory it executes the
validation query which starts a transaction, so later on when the
springs transaction manager tried to set the transaction isolation the
exception is thrown.

While debugging I called commit on the connection after the validation
query had been executed and all worked OK.

I believe this to be a bug, should I log it?


Ben Short

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message