[dbcp] Narayana with DBCP using XADataSource

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[dbcp] Narayana with DBCP using XADataSource

Marián Macik

I am trying to use Narayana transaction manager with Apache Commons
DBCP. The issue is that I would like to use XA DataSource and there is a
very small amount of documentation about how to set DBCP with XA. From
what I read I understood that I should probably use
BasicManagedDataSource instead of BasicDataSource, which is only for
non-XA connections, right?

The other thing is that now I have 3 options according to

1. Use ordinary driverClassName from BasicDataSource - it will create
non-XA connection factory which is then wrapped by xaConnectionFactory.

2. Set xaDataSource which is of type String - so I will provide e.g.
oracle.jdbc.xa.client.OracleXADataSource and then if I haven't created
instance myself it will be created for me inside createConnectionFactory

Here the biggest question is - How then I provide/set e.g. URL to the
data source if it is created without any additional calls in the middle
of the initialization of whole DBCP - I cannot call
getXaDataSourceInstance and call setUrl myself because the DBCP will
have been already initialized by then. User and password are obtained
via getUser/getPassword methods, so this is OK. GetUrl method is used
only inside BasicDataSource and it is not used on xaDataSource instance.

3. Create oracle.jdbc.xa.client.OracleXADataSource myself, call methods
I want to call on it and set it on the BasicManagedDataSource.

After that I guess I just need to set Narayana TransactionManager via
BasicManagedDataSource.setTransactionManager method and I should be good
to go, right?

Thank you very much for answers. The biggest question for me is the
point no. 2 - if DBCP creates XADataSource for me automatically - where
does it set the URL, driverType and other properties in case they are
needed? At least the URL is mandatory.

Best regards,

Marian Macik

To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]