[Biojava-dev] JDBCPooledDataSource regression

Andy Yates ayates at ebi.ac.uk
Wed Jan 31 12:06:17 UTC 2007


Hi,

Sorry I was meaning if that if that method just becomes:

public static DataSource getDataSource(final String driver,
                                          final String url,
                                          final String user,
                                          final String pass)
     throws Exception {

     BasicDataSource ds = new BasicDataSource();
     ds.setUrl(url);
     ds.setDriverClassName(driver);
     ds.setUsername(user);
     ds.setPassword(pass);
     // Set BasicDataSource properties such as maxActive and maxIdle, as 
described in
     // 
http://jakarta.apache.org/commons/dbcp/api/org/apache/commons/dbcp/BasicDataSource.html
     ds.setMaxActive(10);
     ds.setMaxIdle(5);
     ds.setMaxWait(10000);

     return ds;
   }

Does that still work?

I think the original rationale was to ensure that any two datasources do 
actually point to the same resource. However this seems a bit too much 
defensive programming & I don't know why anyone would program themselves 
into a situation where this is required.

Andy

Thomas Down wrote:
> 
> On 31 Jan 2007, at 11:06, Andy Yates wrote:
> 
>> Hi,
>>
>> I would say that this class' method is trying to do too much. We have a
>> method which is creating a BasicDataSource then not bothering to return
>> it in favour of a custom one which implements a hashcode & equals
>> method. Can you try your test case when it returns the BasicDataSource &
>> not the custom one and see if that works please?
> 
> Patching the current revision to return a PoolingDataSource (I assume 
> that's what you meant) rather than a MyPoolingDataSource works fine.  
> However, patching revision 1.3 the same way does not work.  The problem 
> I reported is definitely orthogonal to the question of exactly which 
> type of PoolingDataSource gets returned.
> 
> I'm not sure what the original rationale was for returning the custom 
> PoolingDataSource subclass -- but I can't really see how it's going to 
> do any harm.
> 
>            Thomas.



More information about the biojava-dev mailing list