Comments (12)
I do see a few things that do look suspicious to me:
-
Why do you need to unwrap the connection? The reason why the BTM pool wraps them is to intercept your statement creation calls to be able to enlist the connection into the transaction, i.e.: know what connection participates into what transaction. By using the unwrapped connection directly you bypassed this logic so BTM is unaware of what's going on. Don't do that.
-
Since you're using both JMS and JDBC in the same method together with a transaction manager I guess that you're willing to create a transaction that can either commit or rollback both atomically. If you don't create a BTM JMS connection pool, your JMS connections won't participate in the same transaction as your JDBC connections do, so rolling back the transaction will only rollback your JDBC work.
-
The Spring @transaction annotation does not rollback on exception by default, at least as far as I remember. You have to parameterize the annotation with
rollbackFor=Throwable.class
fr instance to make that happen.
from btm.
I need the native connection to create an oracle array which is only available through oracle.jdbc.OracleConnection.
Example : Array array1= ((oracle.jdbc.OracleConnection) conn).createOracleArray("VARCHAR2", arrayObject);
from btm.
Fine, create the array with the unwrapped connection object, but do everything else with the wrapped one.
from btm.
Agreed. This is true of any connection pool, especially in a transaction manager... ie the wrapped Connection should be used for everything possible, and standard JDBC API methods as much as possible too. It is pretty easy, and common practice, to unwrap the Connection only in very specific code blocks when non-standard JDBC functionality is needed.
from btm.
Thanks @lorban and @jonesde this works fine. the only issue which i see now is, I need to call a Stored Procedure (SP) from java callablestatement passing the arrayobject as one parameter.
- with Drivermanager.getconnection of oracl connection the SP returns success .
- with poolingdatasource.getconnection() at runtime invoked from my server the SP returns failure.
Where exactly could the issue be? java or SP?
from btm.
No idea, could be both.
You could try to unwrap the callable statement before executing it to see if that makes any difference. But it could very well be that your SP does something that is forbidden in a XA transaction context.
from btm.
approach1:
OracleConnection nativeConnection = conn.unwrap(OracleConnection.class);
java.sql.Array array1= nativeConnection.createOracleArray("VARCHAR",arrayName);
CallableStatement stmt = conn.prepareCall({"call SP1(?,?)"}); // This is java.sql.Connection which is bound to BTM
In this approach, SP returns ERROR.
Approach2:
OracleConnection nativeConnection = conn.unwrap(OracleConnection.class);
java.sql.Array array1= nativeConnection.createOracleArray("VARCHAR",arrayName);
CallableStatement stmt = nativeConnection.prepareCall({"call SP1(?,?)"}); // This is nativeConnection
In this approach, SP returns Success.(But the problem with this approach is the callable statement is not bound to java.sql.connection which we got from poolingdatasource )
from btm.
That doesn't invalidate what I've said: it could very well be that your SP does something that is forbidden in a XA transaction context.
As an experiment, you could try to force enlistment of the XAResource and work with the native connection. Simply execute SELECT 1 FROM DUAL
using the wrapping connection right before using the unwrapped one should make sure the connection is bound to the XA transaction's context and should allow you to freely use the unwrapped connection.
from btm.
Thanks @lorban , Issue fixed. COMMIT was inside the Procedure which shouldn't be
from btm.
one last thing. do we need to close the connection which we unwrapped for performing the native connection operations?
from btm.
Definitely not, but you do have to close the wrapping one.
from btm.
got it!
from btm.
Related Issues (20)
- MySQL 8 support HOT 1
- How to configure log4j debug logs for bitrnix
- XAFactories which implement java.util.Map (MQXAConnectionFactory) cannot be initialized properly HOT 3
- Why is there no activity on the Bitronix github? HOT 2
- Using bitronox manager, XA not working with my custom dev-kit adapter HOT 7
- Transaction Manager problem HOT 1
- Glad to see the BTM project active again
- searching best solution for error handling HOT 1
- Error show in tomcat logs HOT 2
- Connection pool unable to recover after database connectivity loss HOT 1
- Question on rollback HOT 1
- Clarify requirements for XAResourceProducer unique name HOT 3
- Support custom XAResourceProducer implementations in ResourceLoader HOT 1
- Transaction Timeout Not working HOT 1
- Using ActiveMQ and bitronix-transaction-manager redelivery issue HOT 1
- Data Security Issue : Vendor property password is getting logged without masking HOT 1
- XA making multiple connections with MQ manager HOT 3
- Is it possible to recover heuristic exception.
- Is it possible to release 3.x?
- Issues related to spring cloud + feign HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from btm.