0

I tried changing the connection pool of my webapp from c3p0 to hikaricp.

here is my configuration.

<bean id="dataSource"
    class="org.hibernate.hikaricp.internal.HikariCPConnectionProvider">

    <property name="dataSourceClassName" value="${hikari.dataSourceClassName}" />
    <property name="maximumPoolSize" value="${hikari.maximumPoolSize}" />
    <property name="maxLifetime" value="${hikari.maxLifetime}" />
    <property name="idleTimeout" value="${hikari.idleTimeout}" />

    <property name="dataSourceProperties">
        <props>
            <prop key="url">${jdbc.url}</prop>
            <prop key="user">${jdbc.username}</prop>
            <prop key="password">${jdbc.password}</prop>
        </props>
    </property>
</bean>

i am getting an error.

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'dataSourceClassName' of bean class [org.hibernate.hikaricp.internal.HikariCPConnectionProvider]: Bean property 'dataSourceClassName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:231)
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:423)
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514)
    ... 32 more

Thanks in advance for the help.

pat3ck029
  • 263
  • 1
  • 7
  • 19

1 Answers1

2

org.hibernate.hikaricp.internal.HikariCPConnectionProvider is not a javax.sql.DataSource. It's an internal component of Hibernate.

Change your configuration to use com.zaxxer.hikari.HikariDataSource instead of org.hibernate.hikaricp.internal.HikariCPConnectionProvider

Jérémie B
  • 10,611
  • 1
  • 26
  • 43