commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno P. Kinoshita (JIRA)" <>
Subject [jira] [Resolved] (DBCP-471) Cannot use connectionInitSqls property in BasicDataSource
Date Thu, 27 Oct 2016 09:57:58 GMT


Bruno P. Kinoshita resolved DBCP-471.
    Resolution: Not A Problem
      Assignee: Bruno P. Kinoshita

Marking the issue as Not A Problem.

The issue happens in the other library (Spring in this case), not really in Commons Dbcp.

Having symmetrical getter and setter types could be discussed, but having some arguments,
and use cases would be helpful.

The issue can be solved using any recent release, either 4.x or 3.x. Or it can also be solved
wrapping the Commons Dbcp with another class, like:

import org.apache.commons.dbcp2.BasicDataSource;

public class MyBasicDataSource extends BasicDataSource {

    public List<String> getConnectionInitSqls() {
        return super.getConnectionInitSqls();

    public void setConnectionInitSqls(List<String> arg0) {


And then just update the bean to use this class instead of BasicDataSource.

> Cannot use connectionInitSqls property in BasicDataSource
> ---------------------------------------------------------
>                 Key: DBCP-471
>                 URL:
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 2.1.1
>            Reporter: happybuddha
>            Assignee: Bruno P. Kinoshita
> Error : 
> {code}Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property
'connectionInitSqls' of bean class [org.apache.commons.dbcp2.BasicDataSource]: Bean property
'connectionInitSqls' 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.setPropertyValue(
> 	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(
> 	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(
> {code}
> Configuration : 
> {code}
>   <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
>     <property name="driverClassName" value="${database.driverClassName}" />
>     <property name="url" value="${database.url}" />
>     <property name="username" value="${database.username}" />
>     <property name="password" value="${database.password}" />
>     <property name="connectionInitSqls">
>     <list>
>     	<value>Select 1 from dual;</value>
>     </list>
>     </property>
>   </bean>
> {code}
> Similar issue for another bean :
> The property is listed as a List<String>, has a getter which returns a List<String>
but has a setter which takes a Collection<String> 
> This is also not in line with what was in versions before 2 (dbcp.BasicDataSource)

This message was sent by Atlassian JIRA

View raw message