You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Bruno P. Kinoshita (JIRA)" <ji...@apache.org> on 2016/10/27 09:57:58 UTC

[jira] [Resolved] (DBCP-471) Cannot use connectionInitSqls property in BasicDataSource

     [ https://issues.apache.org/jira/browse/DBCP-471?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

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:

{code}
import org.apache.commons.dbcp2.BasicDataSource;

public class MyBasicDataSource extends BasicDataSource {

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

    public void setConnectionInitSqls(List<String> arg0) {
        super.setConnectionInitSqls(arg0);
    }

}
{code}

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

> Cannot use connectionInitSqls property in BasicDataSource
> ---------------------------------------------------------
>
>                 Key: DBCP-471
>                 URL: https://issues.apache.org/jira/browse/DBCP-471
>             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(BeanWrapperImpl.java:1042)
> 	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:902)
> 	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
> {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 : https://issues.apache.org/jira/browse/DBCP-469
> 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
(v6.3.4#6332)