Author |
Message
|
bab |
Posted: Sun Aug 21, 2016 10:16 pm Post subject: How to handle commit and rollback in Java method? |
|
|
Novice
Joined: 05 Jul 2016 Posts: 17
|
Hi ...
I am trying to commit database connection explicitly inside java method.
I know Compute and Java Compute nodes are handling commit and rollback automatically.
But I need to handle commit and rollback explicitly in java method(Calling java method from ESQL).
I can able to commit and rollback explicitly if i am using Class.forName(DRIVER_NAME) within the same method in java.
I want to do some DML operations in one method and i want commit those transactions in another java method(when the flow gets successful).
Is there any way to commit and rollback explicitly other than the default mode handle by Compute and Java Compute nodes? |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Aug 22, 2016 4:06 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You would probably (probably! I don't know for sure) store the JDBC session, so that you could commit it later.
You could also use propagate to send a message downstream, and catch any errors that came back in the original javacompute , and roll back the transaction if an error occurred or commit it if it didn't.
But you would have to make sure that all relevant nodes downstream didn't have automatic transaction turned on. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
bab |
Posted: Mon Aug 22, 2016 4:34 am Post subject: |
|
|
Novice
Joined: 05 Jul 2016 Posts: 17
|
Thanks for your reply. It could be better if you say how to store session ? Store in global cache or which format? |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Aug 22, 2016 5:12 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
bab wrote: |
Thanks for your reply. It could be better if you say how to store session ? Store in global cache or which format? |
It would be better, I'm sure. But I don't really have an opinion, or solid knowledge.
The global cache can't store objects, as far as I know. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
bab |
Posted: Mon Aug 22, 2016 9:35 pm Post subject: |
|
|
Novice
Joined: 05 Jul 2016 Posts: 17
|
Yes. You are correct. I tried to storing the connection object inside global cache, it is throwing error.
Looking for alternate solution... |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Aug 23, 2016 3:51 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
bab wrote: |
Yes. You are correct. I tried to storing the connection object inside global cache, it is throwing error.
Looking for alternate solution... |
Looking where? By asking here? Maybe it's quicker for you to look on IBM's website, in the knowledge center for IIB. Maybe it's quicker for you to use the search function of this website to find previous discussion of the global cache.
No matter what, you should do your own experiments and try several different ways to do what you want. Is the global cache a good choice here? Is it absolutely necessary for what you want to do? Are there other options that may be better? _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
eammnsh |
Posted: Sat Oct 08, 2016 3:42 am Post subject: |
|
|
Apprentice
Joined: 22 Aug 2016 Posts: 29
|
Just make sure of setting the "jdbcProviderXASupport" value to false in your JDBC configurable service, to be able to commit/rollback your transaction from your java compute nodes. |
|
Back to top |
|
 |
leron8 |
Posted: Wed Oct 26, 2016 7:14 am Post subject: |
|
|
 Novice
Joined: 25 Oct 2016 Posts: 20 Location: MX
|
eammnsh wrote: |
Just make sure of setting the "jdbcProviderXASupport" value to false in your JDBC configurable service, to be able to commit/rollback your transaction from your java compute nodes. |
This solution worked for me, from IIB 10.0.0.6 and DB2 on an iSeries. |
|
Back to top |
|
 |
|