Search code examples
javahibernatemavenconfigurationc3p0

C3p0 with Hibernate 4.2 error: setCharacterStream(ILjava/io/Reader;J)V is abstract


I am using Hibernate 4.2 with c3p0 and I am getting this error:Method com/mchange/v2/c3p0/impl/NewProxyPreparedStatement.setCharacterStream(ILjava/io/Reader;J)V is abstract

Anybody knows which version should I use? Here is my current Maven dependencies list:

<dependency>
    <groupId>com.mchange</groupId>
    <artifactId>c3p0</artifactId>
    <version>0.9.2</version>
</dependency>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-c3p0</artifactId>
    <version>4.2.0.Final</version>
</dependency>        

Solution

  • The PreparedStatement.setCharacterStream() method was added to JDBC 4 and according to C3P0 release notes:

    As of version 0.9.5, c3p0 fully supports the jdbc4 spec.

    So you need to update the C3p0 library to 0.9.5:

    <dependency>
        <groupId>com.mchange</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.5</version>
    </dependency>
    

    You might also exclude the C3P0 dependency from Hibernate, to make sure Maven uses the one you configured explicitly:

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-c3p0</artifactId>
        <version>4.2.0.Final</version>
        <exclusions>
            <exclusion>
                <artifactId>c3p0</artifactId>
                <groupId>c3p0</groupId>
            </exclusion>
        </exclusions>
    </dependency>