vladmihalcea / flexy-pool

FlexyPool adds metrics and failover strategies to a given Connection Pool, allowing it to resize on demand.
Apache License 2.0
1.09k stars 120 forks source link

Does flexy-pool supports DB2 and Oracle Datasources? #31

Closed Ahmed-A-Syed closed 8 years ago

Ahmed-A-Syed commented 8 years ago

We uses the below connection pools in our application 1) DB2DataSource 2) OracleDataSource

Does current flexy-pool supports DB2 and Oracle Datasources? Can we implement flexypool metrics and failover strategies to the above connection pools? I didn't find any specific doc or example code related to it under vladmihalcea's flexypool github repository.

Could you please suggest on this?

vladmihalcea commented 8 years ago

FlexyPool supports the most common Java connection pools. I'm not sure if DB2DataSource or OracleDataSource provide connection pooling capabilities.

You can always use the flexy-java-ee for any generic DataSource, which will provide metrics without fallback.

For fallback, you need to translate the timeout exception and be able to set the max pool size. Something like this AtomikosPoolAdapter.

So, it's very easy to provide two new adapters for Oracle and DB2. Send me a Pull Request if you do it, and I will integrate it.

Ahmed-A-Syed commented 8 years ago

I didn't get u...! could you please explore a bit more my current configuration is like below. i want to have flexypool features dynamic connection pool setings, monitoring, fallback etc; what all changes are to be done from my side to get flexypool benefits?

   <bean id="ds" class="com.ibm.db2.jcc.DB2DataSource">
    <property name="user" value="${db2User}" />
       .......
               .......
               .......
</bean> 

<bean id="db2ConnFactory" class="org.apache.commons.dbcp.DataSourceConnectionFactory">
    <constructor-arg ref="ds" />
</bean> 
vladmihalcea commented 8 years ago

First of all, com.ibm.db2.jcc.DB2DataSource does not support connection pooling at all.

What you need to do is use HickariCP to wrap the com.ibm.db2.jcc.DB2DataSource. FlexyPool supports KikariCP as illustrated in the Installation Guide.

You can take a look on these Spring configurations folder for a way to integrate HikariCP with FlexyPool.

It's very easy.

Ahmed-A-Syed commented 8 years ago

we already have a connection pool like below:

   <bean id="db2ConnPool" class="org.apache.commons.pool.impl.GenericObjectPool"
    destroy-method="close">
    <property name="maxActive" value="40" />
    .......
    .......
    .......
    </bean>
vladmihalcea commented 8 years ago

I guess you are using DBCP, in which case it's better to use BasicDataSource as suggested in the Installation Guide. FlexyPool doe snot support Common Pools directly without DBCP.

Ahmed-A-Syed commented 8 years ago

Yes..but we were not using BasicDataSource, PoolingDataSource is being used. Can I use flexy pool with PoolingDataSource the similarway mentioned in above BasicDataSource installation guide

<bean id="pooledDB2DS" class="org.apache.commons.dbcp.PoolingDataSource">
    <constructor-arg ref="db2ConnPool" />
</bean>
vladmihalcea commented 8 years ago

ObjectPool is not currently supported, so FlexyPool does not support PoolingDataSource either.

You can add support for it and send me a Pull Request, or you can switch to using a BasicDataSource.

Ahmed-A-Syed commented 8 years ago

ok. will try to check the above options. anyway thanks for the quick response and info.

vladmihalcea commented 8 years ago

You're welcome.

vladmihalcea commented 8 years ago

Closed.